Пример #1
0
        public void SendPacket <T>(T packet, Packets packetType) where T : class
        {
            if (!Connected)
            {
                return;
            }
            Envelope envelope = new Envelope
            {
                PacketType = packetType,
                Packet     = SerializationHandler.Serialize(packet, _bufferSize - 512)
            };
            byte error;

            byte[] message = SerializationHandler.Serialize(envelope, _bufferSize);
            NetworkTransport.Send(_socketID, ClientID, _channelID, message, _bufferSize, out error);
        }
Пример #2
0
        public void SendPacket <T>(T packet, Packets packetType, int clientID) where T : class
        {
            if (!ConnectionManager.Instance.GetClientConnected(clientID))
            {
                return;
            }
            Envelope envelope = new Envelope
            {
                PacketType = packetType,
                Packet     = SerializationHandler.Serialize(packet, _bufferSize - 512)
            };
            byte error;

            byte[] message  = SerializationHandler.Serialize(envelope, _bufferSize);
            int    socketID = _ports[ConnectionManager.Instance.GetClientPort(clientID)];

//            Thread.Sleep(200);
            NetworkTransport.Send(socketID, clientID, _channelID, message, _bufferSize, out error);
        }