Ejemplo n.º 1
0
        private void ConnectCallback(IAsyncResult ar)
        {
            try
            {
                _socket.EndConnect(ar);

                _protocol = new PacketProtocol();
                _protocol.MessageArrived += _protocol_MessageArrived;
                StartReceive();

                using (PacketWriter writer = new PacketWriter())
                {
                    writer.Write(_connectOperationId);
                    writer.Write(SERVERDATA_AUTH);
                    writer.Write(Encoding.ASCII.GetBytes(_rconPassword));
                    writer.Write(0); //null terminated string
                    writer.Write(0); //empty

                    SendPacket(writer.Data);
                }
            }
            catch
            {
                RconOperationEventArgs result;
                lock (_currentOperationsLock) result = _currentOperations[_connectOperationId];
                result.Result = RconOperationResult.ConnectFailed;
                FinalizeResultObject(_connectOperationId);
            }
        }
Ejemplo n.º 2
0
 protected void SendPacket(byte[] packet)
 {
     byte[] fullPacket = PacketProtocol.CreateMessage(packet);
     _socket.BeginSend(fullPacket, 0, fullPacket.Length, SocketFlags.None, SendPacketCallback, null);
 }