/// <summary> /// Multicasts a packet to all users in this room /// </summary> /// <param name="packet"></param> public void MulticastPacket(ServerBasePacket packet) { var data = packet.Write(); // Multicast data to all sessions foreach (var session in _sessions.Values) { if (packet.HighPriority) { session.Send(data); } else { session.SendAsync(data); } } if (Program.Configuration.Global.LogAllPackets) { $"[S] 0x{packet.GetId():x2} {packet.GetType()} >>> ALL".Info(); } // TODO: Add config here - if debug // Temp disable to lessen spam //Console.WriteLine("[S] 0x{0:x2} {1} >>> room: {2}", Color.Green, packet.GetId(), packet.GetType(), Id); }
/// <summary> /// Multicasts a packet to all users in this room /// </summary> /// <param name="packet"></param> private void MulticastPacket(ServerBasePacket packet) { var data = packet.Write(); // Multicast data to all sessions foreach (var session in _sessions.Values) { session.SendAsync(data); } }
/// <summary> /// Send a packet to this client /// </summary> /// <param name="packet"></param> public void SendPacket(ServerBasePacket packet) { var data = packet.Write(); if (packet.HighPriority) { Send(data); } else { SendAsync(data); } if (Program.Configuration.Global.LogAllPackets) { $"[S] 0x{packet.GetId():x2} {packet.GetType()} >>> {GetUserName()}".Info(); } // TODO: Add config here - if debug // TODO: Temp disabled to mute spam // Console.WriteLine("[S] 0x{0:x2} {1} >>> {2}", Color.Green, packet.GetId(), packet.GetType(), GetUserName()); }
/// <summary> /// Sends a response to this packet /// </summary> /// <param name="msg"></param> protected void SendPacket(ServerBasePacket msg) { GetClient().SendPacket(msg); }