Пример #1
0
        /**
         * Sends the specified request through the specified access point, and
         * registers the specified ResponseCollector for later notification.
         * @param  request     the request to send
         * @param  sendTo      the destination address of the request.
         * @param  sendThrough the access point to use when sending the request
         * @param  collector   the instance to notify when a response arrives or the
         *                     the transaction timeouts
         * @throws StunException
         * ILLEGAL_STATE if the stun stack is not started. <br/>
         * ILLEGAL_ARGUMENT if the apDescriptor references an access point that had
         * not been installed <br/>
         * NETWORK_ERROR if an error occurs while sending message bytes through the
         * network socket. <br/>
         *
         */
        public virtual void SendRequest(Request request,
                                        StunAddress sendTo,
                                        NetAccessPointDescriptor sendThrough,
                                        ResponseCollector collector)
        {
            stunStack.CheckStarted();

            StunClientTransaction clientTransaction =
                new StunClientTransaction(this,
                                          request,
                                          sendTo,
                                          sendThrough,
                                          collector);

            clientTransactions[clientTransaction.GetTransactionID()] =
                clientTransaction;
            clientTransaction.SendRequest();
        }
Пример #2
0
        /**
         * Creates a client transaction
         * @param providerCallback the provider that created us.
         * @param request the request that we are living for.
         * @param requestDestination the destination of the request.
         * @param apDescriptor the access point through which we are supposed to
         * @param responseCollector the instance that should receive this request's
         * response.
         * retransmit.
         */
        public StunClientTransaction(StunProvider providerCallback,
                                     Request request,
                                     StunAddress requestDestination,
                                     NetAccessPointDescriptor apDescriptor,
                                     ResponseCollector responseCollector)
        {
            this.providerCallback   = providerCallback;
            this.request            = request;
            this.apDescriptor       = apDescriptor;
            this.responseCollector  = responseCollector;
            this.requestDestination = requestDestination;

            this.transactionID = TransactionID.CreateTransactionID();

            request.SetTransactionID(transactionID.GetTransactionID());

            runningThread = new Thread(new ThreadStart(this.Run));
        }
Пример #3
0
        public static bool VerifyAndGetID(RequestCollector req, ResponseCollector resp)
        {
            int ID = DatabaseController.Class1.StudentList.GetIDByName(req.FamilyName, req.FirstName, req.FathersName, req.Grade, req.Group);

            switch (ID)
            {
            case 0:
                resp.nameIsWrong = true;
                return(false);

            case -1:
                resp.groupOrGradeIsWrong = true;
                return(false);

            default:
                resp.ID          = ID;
                resp.nameIsWrong = false;
                return(true);
            }
        }
Пример #4
0
        /**
         * Creates a client transaction
         * @param providerCallback the provider that created us.
         * @param request the request that we are living for.
         * @param requestDestination the destination of the request.
         * @param apDescriptor the access point through which we are supposed to
         * @param responseCollector the instance that should receive this request's
         * response.
         * retransmit.
         */
        public StunClientTransaction(StunProvider            providerCallback,
			Request                  request,
			StunAddress              requestDestination,
			NetAccessPointDescriptor apDescriptor,
			ResponseCollector        responseCollector)
        {
            this.providerCallback  = providerCallback;
            this.request           = request;
            this.apDescriptor      = apDescriptor;
            this.responseCollector = responseCollector;
            this.requestDestination = requestDestination;

            this.transactionID = TransactionID.CreateTransactionID();

            request.SetTransactionID(transactionID.GetTransactionID());

            runningThread = new Thread(new ThreadStart(this.Run));
        }
Пример #5
0
        /**
         * Sends the specified request through the specified access point, and
         * registers the specified ResponseCollector for later notification.
         * @param  request     the request to send
         * @param  sendTo      the destination address of the request.
         * @param  sendThrough the access point to use when sending the request
         * @param  collector   the instance to notify when a response arrives or the
         *                     the transaction timeouts
         * @throws StunException
         * ILLEGAL_STATE if the stun stack is not started. <br/>
         * ILLEGAL_ARGUMENT if the apDescriptor references an access point that had
         * not been installed <br/>
         * NETWORK_ERROR if an error occurs while sending message bytes through the
         * network socket. <br/>

         */
        public virtual void SendRequest( Request                  request,
			StunAddress              sendTo,
			NetAccessPointDescriptor sendThrough,
			ResponseCollector        collector )
        {
            stunStack.CheckStarted();

            StunClientTransaction clientTransaction =
                new StunClientTransaction(this,
                request,
                sendTo,
                sendThrough,
                collector);

            clientTransactions[clientTransaction.GetTransactionID()] =
                clientTransaction;
            clientTransaction.SendRequest();
        }