Example #1
0
        public static BaseCommunicationClient FactoryMethod(string clientName)
        {
            BaseCommunicationClient client = null;

            switch (clientName)
            {
            case "dummy":
                client = new DummyCommunicationClient();
                break;

            case "http":
                client = new HttpCommunicationClient();
                break;

            default:
                break;
            }
            return(client);
        }
Example #2
0
        private void AsyncRequest(object parameter)
        {
            CommunicationRequest    reqparam = parameter as CommunicationRequest;
            BaseCommunicationClient client   = CommunicationClientFactory.FactoryMethod(reqparam.clientType);

            client.userAgent = this.userAgent;
            if (null == client)
            {
                return;
            }
            CommunicationResponse response = client.Request(reqparam);

            lock (reqparam) {
                if (response.status == CommunicationResponse.ResponseStatus.SUCCESS)
                {
                    reqparam.callback.OnSuccessCallback(response);
                }
                else
                {
                    reqparam.callback.OnFaildCallback(response);
                }
            }
        }