protected override void OnMonitorReceive(IPAddress address, Guid guid, ushort channel, byte[] data) { Message.Base msg = ReceiveMonitorCommand(data); if (msg.IsType <Message.Negotiation.Channel.UDP>()) { Message.Negotiation.Channel.UDP response = (Message.Negotiation.Channel.UDP)msg; ServerChannel channel_parameters = channels[response.channel]; Message.Negotiation.Parameters param = new Message.Negotiation.Parameters { guid = response.guid, channel = response.channel, type = channel_parameters.type, heartbeat = channel_parameters.parameters.Heartbeat, autoReconnect = !channel_parameters.parameters.disableAutoReconnect }; Connection.Tcp monitor; if (monitors.TryGetValue(param.guid, out monitor)) { UdpConnectionParams udp_param = SendUdpParams(monitor, param); ConnectUdp(udp_param, response); } else { Debug.LogErrorFormat("No monitor channel with guid '{0}' to send UDP negotiation for channel {1}", param.guid, param.channel); } } }
protected void ConnectUdp(Connection.Tcp connection, Message.Negotiation.Parameters param) { UdpConnectionParams udp_params = SendUdpParams(connection, param); lock (pendingUdpConnection) { pendingUdpConnection.Add(udp_params); } }
protected override void OnMonitorReceive(IPAddress address, Guid guid, ushort channel, byte[] data) { Message.Base msg = ReceiveMonitorCommand(data); if (msg.IsType <Message.Negotiation.Channel.UDP>()) { Message.Negotiation.Channel.UDP response = (Message.Negotiation.Channel.UDP)msg; UdpConnectionParams udp_params = null; lock (pendingUdpConnection) { foreach (UdpConnectionParams pending_udp_params in pendingUdpConnection) { if (pending_udp_params.param.guid == response.guid && pending_udp_params.param.channel == response.channel) { udp_params = pending_udp_params; break; } } if (udp_params != null) { pendingUdpConnection.Remove(udp_params); } } if (udp_params != null) { ConnectUdp(udp_params, (Message.Negotiation.Channel.UDP)msg); } else { Debug.LogError("Reiceved UDP connection parameters for unrequested connection."); } } }