Example #1
0
        /// <summary>
        /// Attempts to retrieve the given asset from the server synchronously
        /// </summary>
        /// <param name="uuid">The asset UUID as a string</param>
        /// <returns>Asset</returns>
        public void GetAssetAsync(string uuid, AsyncAssetCallback callBack)
        {
            uuid = Util.FixUuid(uuid);

            //build the request
            ClientRequestMsg request = new ClientRequestMsg(ClientRequestMsg.RequestType.GET, uuid);

            //send request and wait for response
            try
            {
                this.SendRequest(request, callBack);
            }
            catch (SocketException e)
            {
                //a socket exception means we need to signal all waiters
                this.HandleSendError(e);
                throw new AssetServerError(e.Message, e);
            }
        }
Example #2
0
        /// <summary>
        /// Sends the given request to the server
        /// </summary>
        /// <param name="request">The request to send</param>
        private ResponseWaiter SendRequest(ClientRequestMsg request, AsyncAssetCallback callBack)
        {
            ResponseWaiter waiter = new ResponseWaiter();

            waiter.callBack = callBack;
            waiter.type     = request.Type;

            if (!this.QueueGetWaiter(request, waiter))
            {
                lock (_sendSync)
                {
                    //we need to enqueue the right waiter here in the right order
                    lock (_waitingRequests)
                    {
                        _waitingRequests.Enqueue(waiter);
                    }

                    request.Send(_conn);
                }
            }

            return(waiter);
        }
        /// <summary>
        /// Sends the given request to the server
        /// </summary>
        /// <param name="request">The request to send</param>
        private ResponseWaiter SendRequest(ClientRequestMsg request, AsyncAssetCallback callBack)
        {
            ResponseWaiter waiter = new ResponseWaiter();
            waiter.callBack = callBack;
            waiter.type = request.Type;

            if (!this.QueueGetWaiter(request, waiter))
            {
                lock (_sendSync)
                {
                    //we need to enqueue the right waiter here in the right order
                    lock (_waitingRequests)
                    {
                        _waitingRequests.Enqueue(waiter);
                    }

                    request.Send(_conn);
                }
            }

            return waiter;
        }
        /// <summary>
        /// Attempts to retrieve the given asset from the server synchronously
        /// </summary>
        /// <param name="uuid">The asset UUID as a string</param>
        /// <returns>Asset</returns>
        public void GetAssetAsync(string uuid, AsyncAssetCallback callBack)
        {
            uuid = Util.FixUuid(uuid);

            //build the request
            ClientRequestMsg request = new ClientRequestMsg(ClientRequestMsg.RequestType.GET, uuid);

            //send request and wait for response
            try
            {
                this.SendRequest(request, callBack);
            }
            catch (SocketException e)
            {
                //a socket exception means we need to signal all waiters
                this.HandleSendError(e);
                throw new AssetServerError(e.Message, e);
            }
        }