Ejemplo n.º 1
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Server] ReceiveUnconnected {0}. From: {1}. Data: {2}", messageType, remoteEndPoint, reader.GetString(100));
     NetDataWriter wrtier = new NetDataWriter();
     wrtier.Put("SERVER DISCOVERY RESPONSE :)");
     Server.SendDiscoveryResponse(wrtier, remoteEndPoint);
 }
Ejemplo n.º 2
0
 private void ListenerOnNetworkReceiveUnconnectedEvent(
     IPEndPoint remoteEndpoint,
     NetDataReader netDataReader,
     UnconnectedMessageType unconnectedMessageType
     )
 {
     // add later
 }
Ejemplo n.º 3
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Client] ReceiveUnconnected {0}. From: {1}. Data: {2}", messageType, remoteEndPoint, reader.GetString(100));
     if (messageType == UnconnectedMessageType.DiscoveryResponse)
     {
         Client.Connect(remoteEndPoint);
     }
 }
Ejemplo n.º 4
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.DiscoveryRequest)
     {
         Debug.Log("[SERVER] Received discovery request. Send discovery response");
         _netServer.SendDiscoveryResponse(new byte[] {1}, remoteEndPoint);
     }
 }
Ejemplo n.º 5
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.DiscoveryResponse && _netClient.Peer == null)
     {
         Debug.Log("[CLIENT] Received discovery response. Connecting to: " + remoteEndPoint);
         _netClient.Connect(remoteEndPoint);
     }
 }
 void INetEventListener.OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader,
                                                    UnconnectedMessageType messageType)
 {
     if (NetworkReceiveUnconnectedEvent != null)
     {
         NetworkReceiveUnconnectedEvent(remoteEndPoint, reader, messageType);
     }
 }
Ejemplo n.º 7
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader,
                                         UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.DiscoveryRequest)
     {
         Debug.Log("[SERVER] Received discovery request. Send discovery response");
         _netServer.SendDiscoveryResponse(new byte[] { 1 }, remoteEndPoint);
     }
 }
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader,
                                         UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.DiscoveryResponse && _netClient.PeersCount == 0)
     {
         Debug.Log("[CLIENT] Received discovery response. Connecting to: " + remoteEndPoint);
         _netClient.Connect(remoteEndPoint, "sample_app");
     }
 }
Ejemplo n.º 9
0
 public void OnNetworkReceiveUnconnected(
     IPEndPoint remoteEndPoint,
     NetPacketReader reader,
     UnconnectedMessageType messageType)
 {
     Logger.Info(
         "OnNetworkReceiveUnconnected({remoteEndPoint}, {reader}, {messageType}).",
         remoteEndPoint,
         reader,
         messageType);
 }
Ejemplo n.º 10
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader,
                                         UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.Broadcast)
     {
         Debug.Log("[SERVER] Received discovery request. Send discovery response");
         NetDataWriter resp = new NetDataWriter();
         resp.Put(1);
         _netServer.SendUnconnectedMessage(resp, remoteEndPoint);
     }
 }
Ejemplo n.º 11
0
 public void OnNetworkReceiveUnconnected(
     IPEndPoint remoteEndPoint,
     NetPacketReader reader,
     UnconnectedMessageType messageType)
 {
     Logger.Warn(
         "OnNetworkReceiveUnconnected({remoteEndPoint}, {reader}, {messageType}).",
         remoteEndPoint.ToFriendlyString(),
         reader,
         messageType);
 }
Ejemplo n.º 12
0
 public void OnNetworkReceiveUnconnected(
     IPEndPoint remoteEndPoint,
     NetPacketReader reader,
     UnconnectedMessageType messageType)
 {
     Logger.Debug(
         "OnNetworkReceiveUnconnected({remoteEndPoint}, {reader}, {messageType}).",
         remoteEndPoint,
         reader,
         messageType);
     if (m_Session.Connection != null)
     {
         m_Session.Disconnect(EDisconnectReason.Unknown);
     }
 }
Ejemplo n.º 13
0
    void OnDiscoveryResponse(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
    {
        if (messageType != UnconnectedMessageType.DiscoveryResponse)
        {
            return;
        }

        MessageType type = (MessageType)reader.GetUShort();

        if (type != MessageType.DiscoverResponse)
        {
            return;
        }

        DiscoverResponseMessage message = new DiscoverResponseMessage();

        message.Read(reader);

        Manager.AddServer(remoteEndPoint, message.ServerName);
    }
Ejemplo n.º 14
0
 private void Listener_NetworkReceiveUnconnectedEvent(System.Net.IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     Debug.Log("unconnected event");
 }
Ejemplo n.º 15
0
        public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
        {
            string message = reader.GetString();

            Debug.Log($"Unconnected Message Received: {message} from {remoteEndPoint.Address} | {messageType}");
        }
Ejemplo n.º 16
0
 private void OnReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.DiscoveryResponse)
     {
         NetDataWriter writer = new NetDataWriter();
         writer.Put(Pin);
         writer.Put(PlayerName);
         _serverPeer = RunNetworkerTask(() => _networker.Connect(remoteEndPoint, writer));
         Log.Information("Client attempting to connect to server at {endPoint}", remoteEndPoint);
     }
     reader.Recycle();
 }
Ejemplo n.º 17
0
        private static void NetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
        {
            if (messageType == UnconnectedMessageType.DiscoveryRequest)
            {
                string requestString = reader.GetString();
                if (requestString == LANDiscoveryConstants.BROADCAST_REQUEST_STRING)
                {
                    NetDataWriter writer = new();
                    writer.Put(LANDiscoveryConstants.BROADCAST_RESPONSE_STRING);
                    writer.Put(Server.Instance.Port);

                    server.SendDiscoveryResponse(writer, remoteEndPoint);
                }
            }
        }
Ejemplo n.º 18
0
        private void EventBasedNetListenerOnNetworkReceiveUnconnectedEvent(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
        {
            if (messageType != UnconnectedMessageType.DiscoveryRequest)
            {
                return;
            }

            string discoveryMessage = reader.GetString();

            Logger.Info($"Discovery Request from {remoteEndPoint.Host}:{remoteEndPoint.Port}, Message:{discoveryMessage}");

            if (discoveryMessage != DatagramPayload.Version)
            {
                Logger.Info("Versions do not match - ignored");
                return;
            }

            NetDataWriter response = new NetDataWriter();

            response.Put(DatagramPayload.Version);
            _server.SendDiscoveryResponse(response, remoteEndPoint);
        }
Ejemplo n.º 19
0
 private void NetworkReceiveUnconnectedEvent(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.Broadcast && remoteEndPoint.Port == Ports.LobbyScan)
     {
         _processor.ReadAllPackets(reader, remoteEndPoint);
     }
 }
Ejemplo n.º 20
0
 void INetEventListener.OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     if (NetworkReceiveUnconnectedEvent != null)
         NetworkReceiveUnconnectedEvent(remoteEndPoint, reader, messageType);
 }
Ejemplo n.º 21
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
 }
Ejemplo n.º 22
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     // ipv4 only for the moment... maybe someday do ipv6 switch, and then later duplicate suppression
     if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
     {
         netPacketProcessor.ReadAllPackets(reader);
     }
 }
Ejemplo n.º 23
0
 protected void receive_unconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     Log.LogVerbose($"Received unconnected message : {remoteEndPoint.Address.ToString()}");
 }
Ejemplo n.º 24
0
        //============ INetEventListener methods ============//

        /// <inheritdoc />
        public override void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
        {
            base.OnNetworkReceiveUnconnected(remoteEndPoint, reader, messageType);

            if (messageType == UnconnectedMessageType.DiscoveryResponse && _netManager.PeersCount == 0)
            {
                if (TinyNetLogLevel.logDev)
                {
                    TinyLogger.Log("[" + TYPE + "] Received discovery response. Connecting to: " + remoteEndPoint);
                }

                WriteConnectionRequest(s_recycleWriter);

                _netManager.Connect(remoteEndPoint, s_recycleWriter);
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Handles connectionmessages sent from a peer.
 /// </summary>
 /// <param name="remoteEndPoint">Information about the connection.</param>
 /// <param name="reader">Reader of netpacket.</param>
 /// <param name="messageType">What type of message is sent.</param>
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     if (remoteEndPoint.Address.ToString() != localIP.Address.ToString())
     {
         if (messageType == UnconnectedMessageType.DiscoveryRequest)
         {
             manager.SendDiscoveryResponse(writer, remoteEndPoint);
         }
         else if (messageType == UnconnectedMessageType.DiscoveryResponse)
         {
             manager.Connect(remoteEndPoint, writer);
         }
     }
 }
Ejemplo n.º 26
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     Debug.Log("[SERVER] OnNetworkReceiveUnconnected");
 }
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     try
     {
         Console.WriteLine($"OnNetworkReceiveUnconnected");
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Error: {ex.Message}");
     }
 }
Ejemplo n.º 28
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.DiscoveryRequest)
     {
         TEDDebug.Log("[Server] recieved discovery response. connecting to:" + remoteEndPoint.ToString());
         m_netManager.SendDiscoveryResponse(new byte[] { 1 }, remoteEndPoint);
     }
 }
Ejemplo n.º 29
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Server] ReceiveUnconnected: {0}", reader.GetString(100));
 }
        //private NetDataWriter _serverWriter = new NetDataWriter();
        public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
        {
            //if (isServer)
            //{
            //    if (messageType == UnconnectedMessageType.Broadcast)
            //    {
            //        // 服务端接收到广播寻找请求
            //        if (reader.GetUShort() == transport.broadcastKey)
            //        {

            //            //Debug.Log("Server 接收到Broadcast");
            //            _serverWriter.Reset();
            //            _serverWriter.Put(transport.broadcastKey);
            //            _serverWriter.Put(transport.broadcastdata);
            //            transport.netManager.SendUnconnectedMessage(_serverWriter, remoteEndPoint);

            //        }

            //    }
            //}
            //else
            //{
            //    if (reader.GetUShort() == transport.broadcastKey)
            //    {
            //        //Debug.Log("Client 接收到Broadcast返回");
            //        //客户端接收到来自服务端的寻找请求回复
            //        eventQueue.Enqueue(new TransportEventData()
            //        {
            //            type = ENetworkEvent.DiscoveryEvent,
            //            reader = reader,
            //            endPoint = remoteEndPoint

            //        });
            //    }
            //}
        }
Ejemplo n.º 31
0
            public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
            {

            }
Ejemplo n.º 32
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.BasicMessage)
     {
         Debug.Log("[CLIENT] Received discovery response. Connecting to: " + remoteEndPoint);
         if (netMgr.mClient != null && netMgr.mClient.PeersCount == 0)
         {
             netMgr.mClient.Connect(remoteEndPoint, AppConst.AppName);
         }
     }
 }
Ejemplo n.º 33
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Client] ReceiveUnconnected {0}. From: {1}. Data: {2}", messageType, remoteEndPoint, reader.GetString(100));
     if (messageType == UnconnectedMessageType.DiscoveryResponse)
     {
         Client.Connect(remoteEndPoint, "key");
     }
 }
Ejemplo n.º 34
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
 }
Ejemplo n.º 35
0
            public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
            {
                Console.WriteLine("[Server] ReceiveUnconnected {0}. From: {1}. Data: {2}", messageType, remoteEndPoint, reader.GetString(100));
                NetDataWriter wrtier = new NetDataWriter();

                wrtier.Put("SERVER DISCOVERY RESPONSE :)");
                Server.SendDiscoveryResponse(wrtier, remoteEndPoint);
            }
Ejemplo n.º 36
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Server] ReceiveUnconnected: {0}", reader.GetString(100));
 }
Ejemplo n.º 37
0
        private void ServerListener_NetworkReceiveUnconnectedEvent(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
        {
            try
            {
                if (_ShutDown)
                {
                    return;
                }
                if ((remoteEndPoint.Host != "127.0.0.1") && (remoteEndPoint.Host != "[::1]"))
                {
                    VoicePlugin.Log("Refused from {0}", remoteEndPoint);
                    return;
                }
                if (messageType != UnconnectedMessageType.BasicMessage)
                {
                    VoicePlugin.Log("Refused {1} from {0}", remoteEndPoint, messageType);
                    return;
                }

                var hello        = reader.GetString();
                var voiceVersion = reader.GetInt();
                if (voiceVersion != 1)
                {
                    VoicePlugin.Log("Refused v {1} from {0}", remoteEndPoint, voiceVersion);
                    return;
                }
                if ((hello == "GTMPVOICECOMMAND") || (hello == "PUREVOICECOMMAND"))
                {
                    VoicePlugin.Log("Command from {0}", remoteEndPoint);
                    if (IsConnected)
                    {
                        var Connection = Client?.GetFirstPeer();
                        if ((Connection != null) && (Connection.ConnectionState == ConnectionState.Connected))
                        {
                            _netPacketProcessor.Send(Connection, new VoicePaketCommand()
                            {
                                Command = reader.GetString(), Data = reader.GetString()
                            }, DeliveryMethod.ReliableOrdered);
                        }
                    }
                    return;
                }
                if ((hello != "GTMPVOICE") && (hello != "PUREVOICE"))
                {
                    VoicePlugin.Log("Invalid configuration from {0}", remoteEndPoint);
                    return;
                }
                _configuration = new VoicePaketConfig();
                _configuration.Deserialize(reader);

                _lastPureVoicePing = DateTime.Now;

                VoicePlugin.Log("Accept Configuration from {0}", remoteEndPoint);
                if (IsConnected)
                {
                    VoicePlugin.Log("Already connected");
                    return;
                }

                if (_configuration.ClientVersionRequired > VoicePlugin.PluginVersion)
                {
                    if (!_GotWarning)
                    {
                        _GotWarning = true;
                        MessageBox.Show($"{VoicePlugin.Name} outdated. Version {_configuration.ClientVersionRequired} is required. Please update.", "PureVoice Plugin Outdated");
                    }
                    return;
                }
                _lastPureVoicePing = DateTime.Now;
                //VoicePlugin.Log("process VoicePaketConfig {0}", _configuration);
                _needConnection = true;
                StartServerConnection();
            }
            catch (Exception ex)
            {
                VoicePlugin.Log("Invalid Serverpaket from {0}: {1}", remoteEndPoint, ex.Message);
            }
        }