sources/network/rconsession.cpp

branch
protocol5
changeset 130
9f54db6f9922
parent 106
7b156b764d11
child 131
4996c8684b93
equal deleted inserted replaced
108:5900be70c619 130:9f54db6f9922
115 bump_last_ping(); 115 bump_last_ping();
116 } 116 }
117 } 117 }
118 118
119 for (Datagram datagram; m_socket.read (datagram);) 119 for (Datagram datagram; m_socket.read (datagram);)
120 handle_packet (datagram.data, datagram.from); 120 handle_packet (datagram);
121 } 121 }
122 122
123 // ------------------------------------------------------------------------------------------------- 123 // -------------------------------------------------------------------------------------------------
124 // 124 //
125 void RCONSession::handle_packet (Bytestream& packet, const IPAddress& from) 125 void RCONSession::handle_packet (Datagram& datagram)
126 { 126 {
127 if (from != m_address) 127 if (datagram.from != m_address)
128 return; 128 return;
129 129
130 try 130 try
131 { 131 {
132 Bytestream& packet = datagram.data;
133 int32_t header = packet.read_long();
134 int32_t sequenceNumber = (header != 0) ? packet.read_long() : 0;
135 m_interface->print("Recieved packet with header 0x%x and sequence number #%d\n", header, sequenceNumber);
136
132 while (packet.bytes_left() > 0) 137 while (packet.bytes_left() > 0)
133 { 138 {
134 int header = packet.read_byte(); 139 int header = packet.read_byte();
135 140
136 switch (ServerResponse (header)) 141 switch (ServerResponse (header))
185 190
186 m_interface->print ("End of previous messages.\n"); 191 m_interface->print ("End of previous messages.\n");
187 192
188 // Watch sv_hostname so that we can update the titlebar when it changes. 193 // Watch sv_hostname so that we can update the titlebar when it changes.
189 request_watch("sv_hostname"); 194 request_watch("sv_hostname");
195 m_interface->print ("Watch requested.\n");
190 break; 196 break;
191 197
192 case SVRC_UPDATE: 198 case SVRC_UPDATE:
193 process_server_updates (packet); 199 process_server_updates (packet);
194 break; 200 break;
254 } 260 }
255 } 261 }
256 break; 262 break;
257 263
258 case SVRC_YOUREDISCONNECTED: 264 case SVRC_YOUREDISCONNECTED:
259 m_interface->print ("You have been disconnected: %s", packet.read_string().chars()); 265 m_interface->print ("You have been disconnected: %s\n", packet.read_string().chars());
260 m_interface->disconnected(); 266 m_interface->disconnected();
261 break; 267 break;
262 } 268 }
263 } 269 }
264 } 270 }

mercurial