/// <summary> /// Communicate /// </summary> public void Communicate() { while (this.shouldStop == false) { try { CommunicationBase comm = new CommunicationBase(); string msg = comm.ReceiveMsg(this.mTcpClient); if (msg == "Hello Server!") { this.GetMessage(msg); comm.SendMsg("Hi Meter\n", this.mTcpClient); this.GetMessage("主機回傳:Hi Meter"); } else { this.GetMessage(msg); comm.SendMsg("主機回傳:測試", this.mTcpClient); this.GetMessage("主機回傳:測試!"); } } catch { this.shouldStop = true; this.GetMessage("強制關閉連線!"); this.mTcpClient.Close(); } } }