public TcpIpTestForm() { InitializeComponent(); MessageInfoHandle handle = new MessageInfoHandle(ParseMessage); LogHandle log = new LogHandle(Log); tcpClientHelper = new TcpClientHelper(handle, log); tcpServerHelper = new TcpServerHelper(handle, log); this.tcpServerHelper.Parent = this; this.tcpClientHelper.Parent = this; OrgInfo org = new OrgInfo(); org.FullName = "XX×éÖ¯"; org.NickName = "Ì©´ï¼ÝУ"; org.Telephone = "tel"; org.Url = "url"; MessageFactory.InitOrg(org); }
public void WriteData(string str) { try { string data = AddCommand(str); switch (CommunicationParam.InterlockMode) { case InterlockMode.串口: SerialHelper.WriteDataToSerial(data); break; case InterlockMode.TCP服务器: if (TcpServerHelper != null && TcpServerHelper.IsRun) { foreach (Session s in TcpServerHelper.SessionTable.Values) { TcpServerHelper.SendText(s, data); } } break; case InterlockMode.TCP客户端: { TcpClientHelper.SendText(data); } break; //case InterlockMode.UDP: // { // //待添加。 // } // break; default: break; } } catch (Exception) { //Util.WriteLog(this.GetType(), ex); Util.Notify("数据发送异常"); } }