Inheritance: IOperation
        private void InitializeServerConnection(string userName, string userPassword)
        {
            _readBuffer = new byte[OClient.BufferLenght];

            // initiate socket connection
            try
            {
                _socket = new TcpClient(Hostname, Port);
                _socket.ReceiveTimeout = RECIVE_TIMEOUT;
            }
            catch (SocketException ex)
            {
                throw new OException(OExceptionType.Connection, ex.Message, ex.InnerException);
            }

            _networkStream = new BufferedStream(_socket.GetStream());
            _networkStream.Read(_readBuffer, 0, 2);

            OClient.ProtocolVersion = ProtocolVersion = BinarySerializer.ToShort(_readBuffer.Take(2).ToArray());
            if (ProtocolVersion < 27)
                UseTokenBasedSession = false;

            if (ProtocolVersion <= 0)
                throw new OException(OExceptionType.Connection, "Incorect Protocol Version " + ProtocolVersion);

            // execute connect operation
            Connect operation = new Connect(null);
            operation.UserName = userName;
            operation.UserPassword = userPassword;

            Document = ExecuteOperation(operation);
            SessionId = Document.GetField<int>("SessionId");
            _serverToken = Document.GetField<byte[]>("Token");
        }
        private void InitializeServerConnection(string userName, string userPassword)
        {
            _readBuffer = new byte[OClient.BufferLenght];

            // initiate socket connection
            try
            {
                _socket = new TcpClient(Hostname, Port);
            }
            catch (SocketException ex)
            {
                throw new OException(OExceptionType.Connection, ex.Message, ex.InnerException);
            }

            _networkStream = new BufferedStream(_socket.GetStream());
            _networkStream.Read(_readBuffer, 0, 2);

            OClient.ProtocolVersion = ProtocolVersion = BinarySerializer.ToShort(_readBuffer.Take(2).ToArray());

            // execute connect operation
            Connect operation = new Connect();
            operation.UserName = userName;
            operation.UserPassword = userPassword;

            Document = ExecuteOperation(operation);
            SessionId = Document.GetField<int>("SessionId");
        }