Esempio n. 1
0
        // Param == connection to be introduced
        public void Introduce(NATRemote conn)
        {
            Debug.Log("NATServer: Introducing: ", conn.Remote.EndPoint.ToString(), " to: ", Remote.EndPoint.ToString());
            OutgoingMessage message = MessagePool.CreateMessage();

            message.Write(NATMessageType.INTRODUCTION);
            message.Write(conn.Remote.EndPoint);

            Remote.Send(message);

            MessagePool.Recycle(message);
        }
Esempio n. 2
0
        public void HandleIntroductionRequest(IncomingMessage msg)
        {
            NATRemote client = new NATRemote(msg.Remote);

            //Local test
            byte[] addr = { 89, 233, 23, 45 };
            client.Remote.EndPoint.Address = new IPAddress(addr); // Temp

            ulong hostId = msg.ReadUInt64();

            Debug.Log(config.Name, ": Client requested introduction as: External IP: ", client.Remote.EndPoint.ToString(), " and local IP: ");
            Debug.Log(config.Name, ": Received introduction request to hostId: ", hostId.ToString());

            if (registeredHosts.TryGetValue(hostId, out NATHost host))
            {
                Debug.Log(config.Name, ": Host was found... Sending introduction");

                host.Introduce(client);
                client.Introduce(host);
            }
        }