- Timestamp:
- Dec 9, 2012, 8:59:08 PM (12 years ago)
- Branches:
- master
- Children:
- cdb4bec
- Parents:
- 581058c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
r581058c rda692b9 94 94 set_nonblock(sock); 95 95 96 bool broadcast Message;96 bool broadcastResponse; 97 97 while (true) { 98 98 … … 104 104 cout << "Got a message" << endl; 105 105 106 broadcast Message = processMessage(clientMsg, from, vctPlayers, serverMsg);106 broadcastResponse = processMessage(clientMsg, from, vctPlayers, serverMsg); 107 107 108 108 cout << "msg: " << serverMsg.buffer << endl; 109 109 110 if (broadcastMessage) 111 { 110 if (broadcastResponse) 111 { 112 cout << "Should be broadcasting the message" << endl; 113 112 114 vector<Player>::iterator it; 113 115 … … 120 122 else 121 123 { 124 cout << "Should be sending back the message" << endl; 125 122 126 if ( sendMessage(&serverMsg, sock, &from) < 0 ) 123 127 error("sendMessage"); … … 139 143 cout << "MSG contents: " << clientMsg.buffer << endl; 140 144 145 // maybe we should make a message class and have this be a member 141 146 bool broadcastResponse = false; 142 147 … … 186 191 187 192 vctPlayers.push_back(newP); 188 strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with o uther players.");193 strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with other players."); 189 194 } 190 195 … … 221 226 case MSG_TYPE_CHAT: 222 227 { 228 cout << "Got a chat message" << endl; 229 223 230 Player *p = findPlayerByAddr(vctPlayers, from); 224 231 … … 232 239 233 240 stringstream ss; 234 ss << p->name << ": " << clientMsg.buffer << endl;241 ss << p->name << ": " << clientMsg.buffer; 235 242 236 243 strcpy(serverMsg.buffer, ss.str().c_str()); … … 249 256 break; 250 257 } 251 252 return broadcastResponse; 253 } 254 } 258 } 259 260 return broadcastResponse; 261 } 262
Note:
See TracChangeset
for help on using the changeset viewer.