internal void SendPacket(Packet.Packet packet) { if (!_client.Connected) { return; } var buf = new ByteBuf(); packet.Write(buf); var data = buf.Flush(); try { _client.GetStream().Write(data, 0, data.Length); _client.GetStream().Flush(); LastPacketMillis = TimeManager.CurrentTimeMillis; } catch (Exception) { _client.Close(); } }
internal void Broadcast(Packet.Packet packet, bool authenticate = true) { foreach (var networkManager in _networkManagers) { if (authenticate && !networkManager.IsAuthenticate) { continue; } networkManager.SendPacket(packet); } }