コード例 #1
0
        private void HubConnectionRequest(object sender, IncomingConnectionRequestEventArgs e)
        {
            // we have a request from a passive user, we need to be active to connect to him
            if (Settings.ActiveMode)
            {
                var hubConnection = (HubConnection)sender;

                var ea = new ConnectionRequestEventArgs
                {
                    UserNickname  = e.Message.SenderNickname,
                    HubConnection = hubConnection
                };

                OnConnectionRequest(ea);

                if (ea.Cancel)
                {
                    return;
                }

                if (TransferManager.HaveRequest(e.Message.SenderNickname, sender as HubConnection))
                {
                    return;
                }

                // we need to set LocalAddress to allow connection
                e.LocalAddress = LocalTcpAddress;
                TransferManager.AllowConnection(e.Message.SenderNickname, sender as HubConnection);
            }
        }