public static int SendPacketToAllClients(ApiPacketWriter packet) { int count = 0; try { if (SocketSessions.Count == 0) { return(count); } byte[] code = packet.GetCompleteBytes("ApiManager.SendPacketToAllClients"); foreach (ApiClient client in SocketSessions.Values) { if (client.SessionSocket != null && client.SessionSocket.Connected) { client.SendCompletePacket(code); count++; } } } catch (Exception ex) { Logger.Exception(ex); } return(count); }
public override void SendPacket(ApiPacketWriter packet) { try { Logger.PacketACK($" [ApiClient] [SendPacket] {packet}"); SendCompletePacket(packet.GetCompleteBytes(null)); packet.memorystream.Close(); packet.Dispose(); packet = null; } catch { Close(); } }