/// <summary> /// OnError /// </summary> /// <param name="sender"></param> /// <param name="data"></param> void tcpClient_onError(NetTcpClient sender, Common.Model.CommandResult data) { if (null != onError) { onError(sender, data); connectCount++; if (null != writeThread) { writeThread.Abort(); } } ///TODO : PARSE ERROR if (data.id == 999) { if (connectCount < 4) { tryToConnect(); if (msr.WaitOne()) { connect(); } } } }
/// <summary> /// On Send data /// </summary> /// <param name="sender"></param> /// <param name="data"></param> void tcpClient_onSendData(NetTcpClient sender, Common.Model.CommandResult data) { if (null != onSendData) { onSendData(sender, data); } }
void tcpClient_onError(NetTcpClient sender, Common.Model.CommandResult data) { Invoke((Action) delegate { listBox1.Items.Insert(0, sender.host + "- > Error : " + data.message); }); }
void tcpClient_onReceiveData(NetTcpClient sender, Common.Model.CommandResult data) { Invoke((Action) delegate { listBox1.Items.Insert(0, sender.host + "- > Recieve data " + Encoding.UTF8.GetString(data.model as byte[])); }); }
/// <summary> /// Parse recieved data /// </summary> /// <param name="sender"></param> /// <param name="data"></param> void tcpClient_onReceiveData(Common.Network.Core.NetTcpClient sender, Common.Model.CommandResult data) { if (null != onReceiveData) { onReceiveData(sender, data); } parseData(sender, data); }
void t_onReceiveData(NetTcpClient sender, Common.Model.CommandResult data) { string s = Encoding.UTF8.GetString(data.model as byte[]); Invoke((Action) delegate { listBox1.Items.Insert(0, s); }); }
/// <summary> /// Parse data /// </summary> /// <param name="sender"></param> /// <param name="data"></param> private void parseData(Common.Network.Core.NetTcpClient sender, Common.Model.CommandResult data) { if ((null != data) && (null != data.model)) { string cmd = Encoding.UTF8.GetString(data.model as byte[]); // PARSE DATA if (cmd.ToLower().StartsWith("[5308") && cmd.ToLower().EndsWith("]")) { write("[53011]"); } } }