예제 #1
0
        internal bool ApproveConnection(IPEndPoint senderEndpoint, byte[] customData, out string failReason)
        {
            if (ConnectionRequest != null)
            {
                NetConnectRequestEventArgs ea = new NetConnectRequestEventArgs();
                ea.EndPoint     = senderEndpoint;
                ea.CustomData   = customData;
                ea.MayConnect   = true;
                ea.DenialReason = null;

                // ask application
                ConnectionRequest(this, ea);

                failReason = ea.DenialReason;
                return(ea.MayConnect);
            }

            failReason = null;
            return(true);
        }
예제 #2
0
		internal bool ApproveConnection(IPEndPoint senderEndpoint, byte[] customData, out string failReason)
		{
			if (ConnectionRequest != null)
			{
				NetConnectRequestEventArgs ea = new NetConnectRequestEventArgs();
				ea.EndPoint = senderEndpoint;
				ea.CustomData = customData;
				ea.MayConnect = true;
				ea.DenialReason = null;

				// ask application
				ConnectionRequest(this, ea);

				failReason = ea.DenialReason;
				return ea.MayConnect;
			}

			failReason = null;
			return true;
		}
예제 #3
0
 void OnConnectionRequest(object sender, NetConnectRequestEventArgs e)
 {
     // At this point we can approve or deny the incoming connection like this:
     //
     // e.MayConnect = true;
     // e.DenialReason = "Sorry, no lamers!";
     //
     // ... possibly depending on the content of e.CustomData which the client
     // specifies when calling Connect()
 }