Ejemplo n.º 1
0
        private void HandleClientDisconnect(Event netEvent)
        {
            _clientConnectedDic.Remove(netEvent.Peer.ID);
            var clientEventArgs = new PacketReceivedEventArgs(netEvent.Peer.ID);

            OnClientDisconnect(clientEventArgs);
        }
Ejemplo n.º 2
0
        private void HandleConnectEvent(Event netEvent)
        {
#if UNITY_EDITOR
            Debug.Log("Client connected to server - ID: " + _peerServer.ID);
#endif
            var packetReceivedEventArgs = new PacketReceivedEventArgs();
            OnClientConnect(packetReceivedEventArgs);
        }
Ejemplo n.º 3
0
        private void HandleConnectEvent(Event netEvent)
        {
            Console.WriteLine("Client connected - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP);

            netEvent.Peer.Timeout(_udpServerInfo.PeerTimeOutLimit, _udpServerInfo.PeerTimeOutMinimum, _udpServerInfo.PeerTimeOutMaximum);
            _clientConnectedDic[netEvent.Peer.ID] = netEvent.Peer;

            var clientEventArgs = new PacketReceivedEventArgs(netEvent.Peer.ID);

            OnClientConnect(clientEventArgs);
        }
Ejemplo n.º 4
0
        private void HandleReceiveEvent(ref Event netEvent)
        {
            Console.WriteLine("Packet received from - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP + ", Channel ID: " + netEvent.ChannelID + ", Data length: " + netEvent.Packet.Length);

            byte[] packetBytes = new byte[netEvent.Packet.Length];
            netEvent.Packet.CopyTo(packetBytes);
            var packetReceivedEventArgs = new PacketReceivedEventArgs(netEvent.Peer.ID, packetBytes);

            OnPacketReceived(packetReceivedEventArgs);

            netEvent.Packet.Dispose();
        }
Ejemplo n.º 5
0
        private void HandleReceiveEvent(ref Event netEvent)
        {
#if UNITY_EDITOR
            Debug.Log("Packet received from server - Channel ID: " + netEvent.ChannelID + ", Data length: " +
                      netEvent.Packet.Length);
#endif
            byte[] packetBytes = new byte[netEvent.Packet.Length];
            netEvent.Packet.CopyTo(packetBytes);
            var packetReceivedEventArgs = new PacketReceivedEventArgs(packetBytes);
            OnPacketReceived(packetReceivedEventArgs);

            netEvent.Packet.Dispose();
        }
Ejemplo n.º 6
0
 private void OnClientDisconnect(PacketReceivedEventArgs e)
 {
     ClientDisconnected?.Invoke(this, e);
 }
Ejemplo n.º 7
0
 private void OnPacketReceived(PacketReceivedEventArgs packetReceivedEventArgs)
 {
     PacketReceived?.Invoke(this, packetReceivedEventArgs);
 }
Ejemplo n.º 8
0
        private void HandleDisconnectClient(Event netEvent)
        {
            var packetReceivedEventArgs = new PacketReceivedEventArgs();

            OnClientDisconnect(packetReceivedEventArgs);
        }
        private void OnPacketReceived(object sender, PacketReceivedEventArgs packetReceivedEventArgs)
        {
            var clientMessage = new ClientMessage(packetReceivedEventArgs.ClientId, MessageType.Data, packetReceivedEventArgs.Packet);

            _messageQueue.Enqueue(clientMessage);
        }
Ejemplo n.º 10
0
 private void OnClientConnect(PacketReceivedEventArgs packetReceivedEventArgs)
 {
     ClientConnect?.Invoke(this, packetReceivedEventArgs);
 }