Пример #1
0
        public void handleRequestInitalizeHostConnection(NetPeer peer, Network.Messages.Connection.Request.InitalizeHostConnectionMessage message)
        {
            NetPeer wpeer;

            if (_hostPeers.TryGetValue(message.HostSystemId, out wpeer))
            {
                wpeer.Send(_messageHandler.encodeMessage(message), SendOptions.Unreliable);
            }
            else
            {
                Network.Messages.Connection.Response.InitalizeHostConnectionMessage messageNew = new Network.Messages.Connection.Response.InitalizeHostConnectionMessage();
                messageNew.HostFound = false;
            }
        }
Пример #2
0
        public void handleRequestInitalizeHostConnection(NetPeer peer, Network.Messages.Connection.Request.InitalizeHostConnectionMessage message)
        {
            this._hostManager.SaveRemotePublicKey(message.ClientSystemId, message.ClientPublicKey);
            var pair = this._hostManager.CreateNewKeyPairKey(message.ClientSystemId);

            Network.Messages.Connection.Response.InitalizeHostConnectionMessage rs = new Network.Messages.Connection.Response.InitalizeHostConnectionMessage();
            rs.HostSystemId   = this._hostManager.SystemId;
            rs.ClientSystemId = message.ClientSystemId;
            rs.HostPublicKey  = pair.PublicKey;

            this._hostManager.sendMessage(rs);
            if (OnClientInitalizeConnected != null)
            {
                OnClientInitalizeConnected(this, new ClientInitalizeConnectedEventArgs {
                    HostSystemId = message.HostSystemId, ClientSystemId = message.ClientSystemId, ClientPublicKey = message.ClientPublicKey
                });
            }
        }