public void ReConnect() { try { if (m_Client != null) { m_Client.Close(); m_Client = null; } m_InReconnect = true; Connect(); Register(); } catch(Exception myE) { ////m_Log.Error("ReConnect", myE); } }
public void Connect() { try { if (m_Client == null) { setState(ConnectionState.opening); InstanceContext context = new InstanceContext(this); //m_Client = new ServiceReference1.K2RTDSupportClient(context, "NetTcpBinding_IK2RTDSupport"); //Specify the binding to be used for the client. System.ServiceModel.NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.None; //Specify the address to be used for the client. EndpointAddress address = new EndpointAddress("net.tcp://localhost:11000/"); m_Client = new ServiceReference1.K2RTDSupportClient(context, binding, address); //m_Client = new ServiceReference1.K2RTDSupportClient(context, "NetTcpBinding_IK2RTDSupport"); m_Client.InnerChannel.Closed += new EventHandler(InnerChannel_Closed); m_Client.InnerChannel.Opened += new EventHandler(InnerChannel_Opened); m_Client.InnerChannel.Opening += new EventHandler(InnerChannel_Opening); m_Client.InnerChannel.Faulted += new EventHandler(InnerChannel_Faulted); m_Client.InnerDuplexChannel.Opened += new EventHandler(InnerChannel_Opened); //m_Log.Info("Connect:" + m_Client.State.ToString()); } } catch (Exception myE) { ////m_Log.Error("Connect", myE); } }