/// <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); }
/// <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); } }