示例#1
0
 public void SendPacket(AbstractPacketOut packet)
 {
     try
     {
         if (Alive)
         {
             byte   id    = (byte)packet.ID;
             byte[] data  = packet.Data;
             byte[] fdata = new byte[data.Length + 5];
             Utilities.IntToBytes(data.Length).CopyTo(fdata, 0);
             fdata[4] = id;
             data.CopyTo(fdata, 5);
             PrimarySocket.Send(fdata);
             if (PE != null)
             {
                 PE.UsagesTotal[(int)packet.UsageType] += fdata.Length;
             }
         }
     }
     catch (Exception ex)
     {
         SysConsole.Output(OutputType.WARNING, "Disconnected " + PE + " -> " + ex.GetType().Name + ": " + ex.Message);
         if (TheServer.CVars.s_debug.ValueB)
         {
             SysConsole.Output(ex);
         }
         PE.Kick("Internal exception.");
     }
 }
示例#2
0
 public void SendToVisible(Location pos, AbstractPacketOut packet)
 {
     Vector3i cpos = ChunkLocFor(pos);
     foreach (PlayerEntity pe in Players)
     {
         if (pe.CanSeeChunk(cpos))
         {
             pe.Network.SendPacket(packet);
         }
     }
 }
示例#3
0
 public void SendPacket(AbstractPacketOut packet)
 {
     try
     {
         if (Alive)
         {
             byte id = (byte)packet.ID;
             byte[] data = packet.Data;
             byte[] fdata = new byte[data.Length + 5];
             Utilities.IntToBytes(data.Length).CopyTo(fdata, 0);
             fdata[4] = id;
             data.CopyTo(fdata, 5);
             PrimarySocket.Send(fdata);
             if (PE != null)
             {
                 PE.UsagesTotal[(int)packet.UsageType] += fdata.Length;
             }
         }
     }
     catch (Exception ex)
     {
         SysConsole.Output(OutputType.WARNING, "Disconnected " + PE + " -> " + ex.GetType().Name + ": " + ex.Message);
         if (TheServer.CVars.s_debug.ValueB)
         {
             SysConsole.Output(ex);
         }
         PE.Kick("Internal exception.");
     }
 }
示例#4
0
 public void SendToAll(AbstractPacketOut packet)
 {
     for (int i = 0; i < Players.Count; i++)
     {
         Players[i].Network.SendPacket(packet);
     }
 }
示例#5
0
 public void ChunkSendToAll(AbstractPacketOut packet, Vector3i cpos)
 {
     for (int i = 0; i < Players.Count; i++)
     {
         if (Players[i].CanSeeChunk(cpos))
         {
             Players[i].Network.SendPacket(packet);
         }
     }
 }