示例#1
0
        public async Task SendPacket(ServerPacket packet)
        {
            byte[] writeBuffer = packet.GetBytes();
            if (writeBuffer.Length > bufferSize)
            {
                throw new Exception("Write buffer was too large to send!");
            }
            try
            {
                await stream.WriteAsync(writeBuffer, 0, writeBuffer.Length);

                Debug.Log($"Sent packet to client {ID}. Bytes written: {writeBuffer.Length}, pakcet code: {packet.GetPacketCode()}");
            }
            catch
            {
                Debug.Log("Failed to send data to client!");
                Disconnect();
            }
        }
示例#2
0
 internal void SendPacket(TcpClient client, ServerPacket packet)
 {
 }
示例#3
0
 /// <summary>
 /// Sends packet to client with specified ID
 /// </summary>
 /// <param name="packet"></param>
 /// <param name="ID"></param>
 public async void SendPacketToClient(ServerPacket packet, int ID)
 {
     await clients[ID].SendPacket(packet);
 }