Example #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);
 }
Example #2
0
 private void ListenerOnNetworkReceiveUnconnectedEvent(
     IPEndPoint remoteEndpoint,
     NetDataReader netDataReader,
     UnconnectedMessageType unconnectedMessageType
     )
 {
     // add later
 }
Example #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);
     }
 }
Example #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);
     }
 }
Example #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);
     }
 }
Example #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");
     }
 }
Example #9
0
 public void OnNetworkReceiveUnconnected(
     IPEndPoint remoteEndPoint,
     NetPacketReader reader,
     UnconnectedMessageType messageType)
 {
     Logger.Info(
         "OnNetworkReceiveUnconnected({remoteEndPoint}, {reader}, {messageType}).",
         remoteEndPoint,
         reader,
         messageType);
 }
Example #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);
     }
 }
Example #11
0
 public void OnNetworkReceiveUnconnected(
     IPEndPoint remoteEndPoint,
     NetPacketReader reader,
     UnconnectedMessageType messageType)
 {
     Logger.Warn(
         "OnNetworkReceiveUnconnected({remoteEndPoint}, {reader}, {messageType}).",
         remoteEndPoint.ToFriendlyString(),
         reader,
         messageType);
 }
 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);
     }
 }
Example #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);
    }
Example #14
0
 private void Listener_NetworkReceiveUnconnectedEvent(System.Net.IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     Debug.Log("unconnected event");
 }
Example #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}");
        }
Example #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();
 }
Example #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);
                }
            }
        }
Example #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);
        }
Example #19
0
 private void NetworkReceiveUnconnectedEvent(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     if (messageType == UnconnectedMessageType.Broadcast && remoteEndPoint.Port == Ports.LobbyScan)
     {
         _processor.ReadAllPackets(reader, remoteEndPoint);
     }
 }
Example #20
0
 void INetEventListener.OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     if (NetworkReceiveUnconnectedEvent != null)
         NetworkReceiveUnconnectedEvent(remoteEndPoint, reader, messageType);
 }
Example #21
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
 }
Example #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);
     }
 }
Example #23
0
 protected void receive_unconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
     Log.LogVerbose($"Received unconnected message : {remoteEndPoint.Address.ToString()}");
 }
Example #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);
            }
        }
Example #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);
         }
     }
 }
Example #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}");
     }
 }
Example #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);
     }
 }
Example #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

            //        });
            //    }
            //}
        }
Example #31
0
            public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
            {

            }
Example #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);
         }
     }
 }
Example #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");
     }
 }
Example #34
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
 {
 }
Example #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);
            }
Example #36
0
 public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Server] ReceiveUnconnected: {0}", reader.GetString(100));
 }
Example #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);
            }
        }