Exemplo n.º 1
0
        public void handleRequestHostConnection(NetPeer peer, Network.Messages.Connection.Request.HostConnectionMessage message)
        {
            var res = new Network.Messages.Connection.Response.HostConnectionMessage();

            res.HostSystemId   = message.HostSystemId;
            res.ClientSystemId = message.ClientSystemId;
            res.PasswordOk     = false;
            var decrypt = _hostManager.Decode(message.ClientSystemId, message.Password);

            if (this._hostManager.Password == decrypt)
            {
                res.PasswordOk = true;
                var symmetricKey = _hostManager.Decode(message.ClientSystemId, message.SymmetricKey);
                _hostManager.SaveSymmetricKey(message.ClientSystemId, symmetricKey);
            }
            peer.Send(_messageHandler.encodeMessage(res), SendOptions.Unreliable);
            if (OnClientConnected != null)
            {
                OnClientConnected(this, new ClientConnectedEventArgs()
                {
                    SystemId = res.ClientSystemId, PasswordOk = res.PasswordOk
                });
            }
        }