コード例 #1
0
        public TcpConnectionHandler(TcpClient client)
        {
            Receiver    = new TcpReceiver(client);
            Sender      = new TcpSender(client);
            ProcessSema = new Semaphore(1, 1);

            ConnectionMainThread = new Thread(MainLoop);
            ConnectionMainThread.Start();
        }
コード例 #2
0
 public virtual void Init(TcpClient client)
 {
     Receiver             = new TcpReceiver(client);
     Sender               = new TcpSender(client);
     ProcessSema          = new Semaphore(1, 1);
     this.Client          = client;
     ConnectionMainThread = new Thread(MainLoop);
     ConnectionMainThread.Start();
     client.ReceiveTimeout = 100000000;
 }
コード例 #3
0
        public void Disconnect(string reason)
        {
            var jstr = JsonWorker.MakeSampleJson(new string[] { "type", "result", "state" }, new string[] { "1", reason, "200" }).jstr;

            this.Sender.WriteSendData(jstr);
            Client.Client.Disconnect(false);
            Client.Close();

            this.Sender   = null;
            this.Receiver = null;
            this.Client.Dispose();
            ProcessSema.Close();
            ProcessSema = null;

            //ConnectThread.Abort();
            OnDisconnect(reason);
        }