示例#1
0
 /// <summary>
 /// Send a packet to the server.
 /// </summary>
 /// <param name="packet">Packet to send, which will be serialized.</param>
 private async Task SendPacketAsync(RCONPacket packet)
 {
     if (!_connected)
     {
         throw new InvalidOperationException("Connection is closed.");
     }
     await _tcp.SendAsync(new ArraySegment <byte>(packet.ToBytes()), SocketFlags.None);
 }
示例#2
0
文件: RCON.cs 项目: Nerus87/CoreRcon
        /// <summary>
        /// Send a packet to the server.
        /// </summary>
        /// <param name="packet">Packet to send, which will be serialized.</param>
        private async Task SendPacketAsync(RCONPacket packet)
        {
            if (!_connected)
            {
                throw new InvalidOperationException("Connection is closed.");
            }
            await _tcp.SendAsync(new ArraySegment <byte>(packet.ToBytes()), SocketFlags.None);

            if (packet.Type == PacketType.ExecCommand && _multiPacket)
            {
                //Send a extra packet to find end of large packets
                await _tcp.SendAsync(new ArraySegment <byte>(new RCONPacket(packet.Id, PacketType.Response, "").ToBytes()), SocketFlags.None);
            }
        }