Пример #1
0
        public void Send(Packet packet, IEnumerable <Session> sessions)
        {
            var packetStr = Packet.WriteToMessage(packet);

            foreach (var session in sessions)
            {
                session.Send(packetStr);
            }
        }
Пример #2
0
        public void Broadcast(Packet packet, Func <Session, bool> filter = null)
        {
            var packetStr = Packet.WriteToMessage(packet);

            foreach (var session in _sessions.Values)
            {
                if (filter == null || filter(session))
                {
                    session.Send(packetStr);
                }
            }
        }
Пример #3
0
        public void Ping()
        {
            var ping    = new Packets.Ping();
            var pingStr = Packet.WriteToMessage(ping);

            try
            {
                foreach (var host in _server.WebSocketServices.Hosts)
                {
                    host.Sessions.Broadcast(pingStr);
                }
            }
            catch (Exception e)
            {
                Program.Logger.Warn("ping failed", e);
            }
        }
Пример #4
0
        public void Ping()
        {
            var ping    = new Packets.Ping();
            var pingStr = Packet.WriteToMessage(ping);

            try
            {
                foreach (var client in _server.Clients)
                {
                    client.Send(pingStr);
                }
            }
            catch (Exception e)
            {
                Program.Logger.Warn("ping failed", e);
            }
        }
Пример #5
0
 public void Send(Packet packet)
 {
     Send(Packet.WriteToMessage(packet));
 }
Пример #6
0
        public void Send(Packet packet)
        {
            var packetStr = Packet.WriteToMessage(packet);

            Send(packetStr);
        }