private void Fm112x_IMEI(object sender, TcpClient c) { NetworkStream s = c.GetStream(); WriteStream(s, fm112x.ByteAcceptData); PrintHelper.PrintRow(c.Client.ProtocolType.ToString(), c.Client.RemoteEndPoint.ToString(), fm112x.ByteAcceptData.Length.ToString(), "SENDING DATA"); TrafficUtility.AddSentTraffic(fm112x.ByteAcceptData.Length); }
private async void Fm112x_AVLdataArray(object sender, EventArgsAVLdataArray entry) { NetworkStream s = entry.client.GetStream(); WriteStream(s, fm112x.ServerAcknowledgeReceivedData); await Program.connector.WebRequestPostTask(entry.data); PrintHelper.PrintRow(entry.client.Client.ProtocolType.ToString(), entry.client.Client.RemoteEndPoint.ToString(), fm112x.ServerAcknowledgeReceivedData.Length.ToString(), "SENDING DATA"); TrafficUtility.AddSentTraffic(fm112x.ServerAcknowledgeReceivedData.Length); }
private void HandleConnectionAsync(TcpClient client) { PrintHelper.PrintLine(); PrintHelper.PrintRow(client.Client.ProtocolType.ToString(), client.Client.RemoteEndPoint.ToString(), client.Client.Available.ToString(), "ESTABLISHED"); try { byte[] bytes = new Byte[1024]; // 1 KB buffer //string data = null; int i; NetworkStream stream = client.GetStream(); while (true) { //client established correctly while ((i = stream.Read(bytes, 0, bytes.Length)) != 0) { var data = BitConverter.ToString(bytes, 0, i).Replace("-", string.Empty); PrintHelper.PrintRow(client.Client.ProtocolType.ToString(), client.Client.RemoteEndPoint.ToString(), i.ToString(), "RECEIVING DATA"); TrafficUtility.AddReceivedTraffic(i); if (Program.debug) { PrintHelper.PrintDump(data); } fm112x.Parse(client, data); } if (i == 0) { break; } } PrintHelper.PrintRow(client.Client.ProtocolType.ToString(), client.Client.RemoteEndPoint.ToString(), client.Client.Available.ToString(), "CLOSED"); _clients--; clients.Remove(client); } catch (Exception ex) { PrintHelper.Error(ex.Message); LogUtility.WriteErrorLog(string.Format("Message:\n{0}\nStackTrace:\n{1}", ex.Message, ex.StackTrace)); } }