示例#1
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();
            }
 /// <summary>
 /// Sets the callback to be called upon disconnection
 /// </summary>
 /// <param name="callback"></param>
 public void SetDisconnectCallback(OnDisconnectCallback callback) => disconnectCallback = callback;