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