Esempio n. 1
0
 public void ForeachData(OnDataCallback callback)
 {
     foreach (var pair in dataListByID)
     {
         callback(pair.Value);
     }
 }
Esempio n. 2
0
            public AsyncTCPXMLClient(string Hostname,
                                     int Portnumber,
                                     X509Certificate2 Certificate,
                                     bool AllowSelfSignedServerCertificate,
                                     OnDataCallback OnData,
                                     OnDisconnectCallback OnDisconnect,
                                     int DebugLevel)
            {
                this.Hostname    = Hostname;
                this.Portnumber  = Portnumber;
                this.Certificate = Certificate;
                this.AllowSelfSignedServerCertificate = AllowSelfSignedServerCertificate;
                this.OnData       = OnData;
                this.OnDisconnect = OnDisconnect;
                this.DebugLevel   = DebugLevel;

                XMLStream    = new MojsStream();
                Client       = new TcpClient(this.Hostname, this.Portnumber);
                ActiveStream = Client.GetStream();

                Client.SendTimeout = SendTimeout;

                IOThread      = new Thread(new ThreadStart(RunIO));
                IOThread.Name = "DXMPPNet IO";
                IOThread.Start();

                EventsThread      = new Thread(new ThreadStart(RunEvents));
                EventsThread.Name = "DXMPPNet Events";
                EventsThread.Start();

                ParseXMLThread      = new Thread(new ThreadStart(BlockingXMLRead));
                ParseXMLThread.Name = "DXMPPNet Parse XML";
                ParseXMLThread.Start();
            }
Esempio n. 3
0
        private WebRequest(OnDataCallback callback, object userData)
        {
            m_requestId = m_nextRequestId;
            m_nextRequestId++;

            m_onDataCallback = callback;
            m_userData       = userData;
        }
Esempio n. 4
0
        public static WebRequest Delete(string url, Dictionary <string, string> headers, OnDataCallback callback, object userData)
        {
            UnityWebRequest unityWebRequest = UnityWebRequest.Delete(url);

            unityWebRequest.downloadHandler = new DownloadHandlerBuffer();

            foreach (KeyValuePair <string, string> kvp in headers)
            {
                unityWebRequest.SetRequestHeader(kvp.Key, kvp.Value);
            }

            WebRequest webRequest = new WebRequest(callback, userData);

            webRequest.m_request = unityWebRequest;

            return(webRequest);
        }
Esempio n. 5
0
        public static WebRequest Get(string url, Dictionary <string, string> headers, OnDataCallback callback, object userData)
        {
            UnityWebRequest unityWebRequest = UnityWebRequest.Get(url);

            foreach (KeyValuePair <string, string> kvp in headers)
            {
                unityWebRequest.SetRequestHeader(kvp.Key, kvp.Value);
            }

            WebRequest webRequest = new WebRequest(callback, userData);

            webRequest.m_request = unityWebRequest;

            return(webRequest);
        }
Esempio n. 6
0
        public static WebRequest Post(string url, Dictionary <string, string> headers, object jsonObject, OnDataCallback callback, object userData)
        {
            byte[] postData = null;
            if (null != jsonObject)
            {
                postData = Encoding.UTF8.GetBytes(JsonUtility.ToJson(jsonObject));
            }
            UploadHandlerRaw uploadHandlerRaw = new UploadHandlerRaw(postData);

            uploadHandlerRaw.contentType = "application/json";

            UnityWebRequest unityWebRequest = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST);

            unityWebRequest.uploadHandler   = uploadHandlerRaw;
            unityWebRequest.downloadHandler = new DownloadHandlerBuffer();

            foreach (KeyValuePair <string, string> kvp in headers)
            {
                unityWebRequest.SetRequestHeader(kvp.Key, kvp.Value);
            }

            WebRequest webRequest = new WebRequest(callback, userData);

            webRequest.m_request = unityWebRequest;

            return(webRequest);
        }