private void timerCheckConnection_Tick(object sender, EventArgs e) { /* if (rosSocket != null) * { * if (!rosSocket.isConnected) * { * timerCheckConnection.Stop(); * timerConnectRosSocket.Start(); * * } * else * { * dynamic product = new JObject(); * product.count = GlobalVariables.EncodeTransmissionTimestamp(); * StandardString messages = new StandardString(); * messages.data = product.ToString(); * rosSocket.Publish(paramsRosSocket.publication_checkAliveTimeOut, messages); * } * }*/ Console.WriteLine("here check"); if (rosSocket != null) { if (rosSocket.webSocket != null) { if (rosSocket.webSocket.ReadyState.ToString().Equals("Closed")) { rosSocket.isConnected = false; timerCheckConnection.Stop(); timerConnectRosSocket.Start(); } else if (rosSocket.webSocket.ReadyState.ToString().Equals("Open")) { rosSocket.isConnected = true; dynamic product = new JObject(); product.count = GlobalVariables.EncodeTransmissionTimestamp(); StandardString messages = new StandardString(); messages.data = product.ToString(); rosSocket.Publish(paramsRosSocket.publication_checkAliveTimeOut, messages); } Console.WriteLine(rosSocket.webSocket.ReadyState); } else { rosSocket.isConnected = false; timerCheckConnection.Stop(); timerConnectRosSocket.Start(); } } }
public void checkAliveTimeOut(Object sender, EventArgs e) { if (rosSocket != null) { if (!rosSocket.isConnected) { timerInterruptCheckAliveTimeOut.Stop(); timerInterruptConnectionRosSocket.Start(); } else { dynamic product = new JObject(); product.count = GlobalVariables.EncodeTransmissionTimestamp(); StandardString messages = new StandardString(); messages.data = product.ToString(); rosSocket.Publish(paramsRosSocket.publication_checkAliveTimeOut, messages); } } }