示例#1
0
        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();
            }
        }
示例#2
0
 internal void Broadcast(Packet.Packet packet, bool authenticate = true)
 {
     foreach (var networkManager in _networkManagers)
     {
         if (authenticate && !networkManager.IsAuthenticate)
         {
             continue;
         }
         networkManager.SendPacket(packet);
     }
 }