示例#1
0
 /// <summary>
 /// Send the carrier to the server with the request code which will be passed to the callback function
 /// </summary>
 /// <param name="requestCode"></param>
 /// <param name="carrier"></param>
 public void Connect(int requestCode, ProviderCarrier carrier)
 {
     Thread thread = new Thread(new ThreadStart(delegate
     {
         _Connect(requestCode, carrier);
     }));
     thread.IsBackground = true;
     thread.Start();
 }
        public void _ConnectTest()
        {
            ProviderCarrier carrier = new ProviderCarrier() { Route = "/login" };
            carrier.ParamList.Add("email", "*****@*****.**");
            carrier.ParamList.Add("pass", "password");
            carrier.ParamList.Add("mode", 1);

            ProviderBridge bridge = new ProviderBridge();
            bridge.Connect(0, carrier);
        }
        public void ToStringTest()
        {
            ProviderCarrier carrier = new ProviderCarrier();
            carrier.Route = "/login";
            carrier.ParamList.Add("email", "*****@*****.**");
            carrier.GenericList.Add("other", "another thing here.");
            carrier.GenericList.Add("money", 3);

            carrier.ToString();
        }
示例#4
0
        public void _Connect(int requestCode, ProviderCarrier carrier)
        {
            if (carrier == null)
            {
                Handle(new ProviderLoadedEventArgs(0, 0, null));
                return;
            }

            int status = 0;
            string json = null;
            HttpWebRequest request = null;
            HttpWebResponse respone = null;

            try
            {
                string uriScheme = ProviderSettings.ToString();
                string equipmentDesc = EquipmentUtils.EquipmentDescription();
                // Payload data to be send
                byte[] payload = Encoding.UTF8.GetBytes(carrier.ToString());

                request = (HttpWebRequest) WebRequest.Create(uriScheme);
                request.Method = "POST";
                request.ContentLength = payload.Length;
                request.UserAgent = equipmentDesc;

                WriteStream(request.GetRequestStream(), payload);

                respone = (HttpWebResponse) request.GetResponse();

                status = (int) respone.StatusCode;

                json = ReadStream(respone.GetResponseStream(), respone.ContentEncoding);
            }
            catch (Exception) {}

            Handle(new ProviderLoadedEventArgs(requestCode, status, json));
        }
示例#5
0
 /// <summary>
 /// Send the carrier to the server
 /// </summary>
 /// <param name="carrier"></param>
 public void Connect(ProviderCarrier carrier)
 {
     Connect(0, carrier);
 }