Esempio n. 1
0
 public void SendPacket(IServerPacket packet)
 {
     lock (Sync) {
         if (!Connection.IsAvailable)
         {
             return;
         }
         Connection.Send(packet.Pack());
     }
 }
Esempio n. 2
0
        public void SendPacket(IServerPacket packet)
        {
            lock (Sync) {
                if (!IsConnected)
                {
                    PacketQueue.Enqueue(packet);
                    return;
                }

                if (!Connection.IsAvailable)
                {
                    return;
                }

                Connection.Send(packet.Pack());
            }
        }
Esempio n. 3
0
        public void Send(IServerPacket packet, int eventId = 0)
        {
            if (!Websocket.IsAvailable)
            {
                return;
            }
            if (eventId < 1)
            {
                eventId = SockChatMessage.NextMessageId; // there needs to be a better solution for this
            }
            IEnumerable <string> data = packet.Pack(Version, eventId);

            if (data != null)
            {
                foreach (string line in data)
                {
                    if (!string.IsNullOrWhiteSpace(line))
                    {
                        Websocket.Send(line);
                    }
                }
            }
        }