equal
deleted
inserted
replaced
56 void NetworkSession::handle_disconnect (NetworkNode *node) { |
56 void NetworkSession::handle_disconnect (NetworkNode *node) { |
57 // remove from nodes |
57 // remove from nodes |
58 nodes.erase(node->getRemoteAddress()); |
58 nodes.erase(node->getRemoteAddress()); |
59 } |
59 } |
60 |
60 |
61 void NetworkSession::handle_message (NetworkPacket &pkt, NetworkNode *node) { |
61 void NetworkSession::handle_message (NetworkPacketInput &pkt, NetworkNode *node) { |
62 // read the channel id |
62 // read the channel id |
63 NetworkChannelID channel_id = pkt.read_uint16(); |
63 NetworkChannelID channel_id = pkt.read_uint16(); |
64 |
64 |
65 // fire signal |
65 // fire signal |
66 _map_sig_chan_message[channel_id](pkt, node); |
66 _map_sig_chan_message[channel_id](pkt, node); |
78 |
78 |
79 // fire signals |
79 // fire signals |
80 _sig_node_connected(client_node); |
80 _sig_node_connected(client_node); |
81 } |
81 } |
82 |
82 |
83 void NetworkSession::on_udp_packet (NetworkPacket &pkt, const NetworkAddress &addr) { |
83 void NetworkSession::on_udp_packet (NetworkPacketInput &pkt, const NetworkAddress &addr) { |
84 NetworkNode *node = nodes[addr]; |
84 NetworkNode *node = nodes[addr]; |
85 |
85 |
86 // drop from unknown sources |
86 // drop from unknown sources |
87 if (!node) { |
87 if (!node) { |
88 Engine::log(WARN, "net_session.on_udp_packet") << "dropping unsolicted UDP packet from " << addr; |
88 Engine::log(WARN, "net_session.on_udp_packet") << "dropping unsolicted UDP packet from " << addr; |
91 |
91 |
92 // handle |
92 // handle |
93 handle_message(pkt, node); |
93 handle_message(pkt, node); |
94 } |
94 } |
95 |
95 |
96 void NetworkSession::send_all (NetworkChannelID channel_id, const NetworkPacket &pkt, bool reliable) { |
96 void NetworkSession::send_all (NetworkChannelID channel_id, const NetworkPacketBuffer &pkt, bool reliable) { |
97 send_all_except(channel_id, pkt, NULL, reliable); |
97 send_all_except(channel_id, pkt, NULL, reliable); |
98 } |
98 } |
99 |
99 |
100 void NetworkSession::send_all_except (NetworkChannelID channel_id, const NetworkPacket &pkt, const NetworkNode *node, bool reliable) { |
100 void NetworkSession::send_all_except (NetworkChannelID channel_id, const NetworkPacketBuffer &pkt, const NetworkNode *node, bool reliable) { |
101 for (std::map<NetworkAddress, NetworkNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) { |
101 for (std::map<NetworkAddress, NetworkNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) { |
102 if (it->second == node) |
102 if (it->second == node) |
103 continue; |
103 continue; |
104 |
104 |
105 it->second->send(channel_id, pkt, reliable); |
105 it->second->send(channel_id, pkt, reliable); |