- Timestamp:
- Nov 26, 2012, 5:55:19 PM (12 years ago)
- Branches:
- master
- Children:
- d2b411a
- Parents:
- 2488852
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r2488852 r0cc431d 43 43 const int BOUNCER_SIZE = 32; 44 44 enum MYKEYS { 45 KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT 45 KEY_UP, 46 KEY_DOWN, 47 KEY_LEFT, 48 KEY_RIGHT 49 }; 50 51 enum STATE { 52 STATE_START, 53 STATE_LOGIN 46 54 }; 47 55 … … 58 66 bool doexit = false; 59 67 68 int state = STATE_START; 69 60 70 chat chatConsole; 61 71 … … 130 140 struct sockaddr_in server, from; 131 141 struct hostent *hp; 132 char buffer[256];142 //char buffer[256]; 133 143 NETWORK_MSG msgTo, msgFrom; 134 144 … … 200 210 cout << "input: " << input << endl; 201 211 strcpy(msgTo.buffer, input.c_str()); 202 212 213 switch(state) 214 { 215 case STATE_START: 216 msgTo.type = MSG_TYPE_LOGIN; 217 break; 218 case STATE_LOGIN: 219 msgTo.type = MSG_TYPE_CHAT; 220 break; 221 default: 222 cout << "The state has an invalid value: " << state << endl; 223 break; 224 } 225 203 226 n=sendMessage(&msgTo, sock, &server); 204 227 if (n < 0) … … 209 232 error("receiveMessage"); 210 233 211 chatConsole.addLine(string(msgFrom.buffer)); 212 cout << "Added new line" << endl; 234 switch(state) 235 { 236 case STATE_START: 237 state = STATE_LOGIN; 238 break; 239 case STATE_LOGIN: 240 chatConsole.addLine(string(msgFrom.buffer)); 241 cout << "Added new line" << endl; 242 break; 243 default: 244 cout << "The state has an invalid value: " << state << endl; 245 break; 246 } 213 247 } 214 248 }else {
Note:
See TracChangeset
for help on using the changeset viewer.