Changeset 777 for code/branches/FICN/src/network/Client.cc
- Timestamp:
- Dec 31, 2007, 7:40:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/Client.cc
r632 r777 1 1 /* 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Oliver Scheuss, (C) 2007 23 * Co-authors: 24 * ... 25 * 26 */ 27 27 28 28 // … … 38 38 // 39 39 40 #include "core/CoreIncludes.h" 40 41 #include "Client.h" 41 42 42 namespace network {43 44 /** 45 46 47 43 namespace network 44 { 45 /** 46 * Constructor for the Client class 47 * initializes the address and the port to default localhost:NETWORK_PORT 48 */ 48 49 Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){ 49 50 // set server address to localhost … … 52 53 53 54 /** 54 55 56 57 55 * Constructor for the Client class 56 * @param address the server address 57 * @param port port of the application on the server 58 */ 58 59 Client::Client(std::string address, int port) : client_connection(port, address){ 59 60 isConnected=false; … … 61 62 62 63 /** 63 64 65 66 64 * Constructor for the Client class 65 * @param address the server address 66 * @param port port of the application on the server 67 */ 67 68 Client::Client(const char *address, int port) : client_connection(port, address){ 68 69 isConnected=false; … … 70 71 71 72 /** 72 73 74 73 * Establish the Connection to the Server 74 * @return true/false 75 */ 75 76 bool Client::establishConnection(){ 76 77 isConnected=client_connection.createConnection(); … … 79 80 80 81 /** 81 82 83 82 * closes the Connection to the Server 83 * @return true/false 84 */ 84 85 bool Client::closeConnection(){ 85 86 isConnected=false; … … 88 89 89 90 /** 90 91 92 93 94 91 * submits a MouseAction to the server 92 * @param x x Coordinate 93 * @param y y Coordinate 94 * @return true/false 95 */ 95 96 bool Client::sendMouse(double x, double y){ 96 97 // generate packet and add it to the queue … … 98 99 return false; 99 100 if(!client_connection.addPacket(pck_gen.mousem(x, y))) 100 101 return false; 101 102 // send packets 102 103 return client_connection.sendPackets(); … … 104 105 105 106 /** 106 107 108 109 107 * submits a Keystrike to the server 108 * @param key_code code to submit 109 * @return true/false 110 */ 110 111 bool Client::sendKeyboard(char key_code){ 111 112 // generate packet and add it to queue … … 113 114 return false; 114 115 if(!client_connection.addPacket(pck_gen.keystrike(key_code))) 115 116 return false; 116 117 // send packets 117 118 return client_connection.sendPackets(); … … 119 120 120 121 /** 121 122 123 124 122 * submits a chat message to the server 123 * @param message message to send 124 * @return true/false 125 */ 125 126 bool Client::sendChat( std::string message ){ 126 127 // generate packet and add it to queue … … 134 135 135 136 /** 136 137 138 139 140 137 * Adds a MouseAction to the PacketQueue 138 * @param x x Coordinate 139 * @param y y Coordinate 140 * @return true/false 141 */ 141 142 bool Client::addMouse(double x, double y){ 142 143 // generate packet and add it to the queue … … 148 149 149 150 /** 150 151 152 153 151 * Adds a Keystrike to the PacketQueue 152 * @param key_code 153 * @return true/false 154 */ 154 155 bool Client::addKeyboard(char key_code){ 155 156 // generate packet and add it to queue … … 161 162 162 163 /** 163 164 164 * Sends out all the packets queued by addXXX 165 */ 165 166 bool Client::sendPackets(){ 166 167 if(!isConnected) … … 176 177 177 178 /** 178 179 179 * Performs a GameState update 180 */ 180 181 void Client::tick(float time){ 181 182 ENetPacket *packet;
Note: See TracChangeset
for help on using the changeset viewer.