public bool Connect() { try { WellKnownClientTypeEntry CoRemote = new WellKnownClientTypeEntry(typeof(RpcConnector), "tcp://" + _Ip + ":" + _Port + "/" + typeof(RpcConnector).Name + _Key); if (_Channel == null) { _Channel = new TcpChannel(); ChannelServices.RegisterChannel(_Channel, false); RemotingConfiguration.RegisterWellKnownClientType(CoRemote); } Log.Info("Connect", "Registering connector : " + CoRemote.ObjectUrl); Connector = (RpcConnector)Activator.GetObject(CoRemote.ObjectType, CoRemote.ObjectUrl); _Id = Connector.Connect(_Name); Log.Success("RpcClient", "Connected to : " + _Ip + ":" + _Port); Load(); } catch (Exception e) { Log.Error("RcpClient", "Can not connect to : " + _Ip + ":" + _Port); Log.Error("RpcClient", "Erreur = " + e.ToString()); try { ChannelServices.UnregisterChannel(_Channel); } catch (Exception) { } _Channel = null; return(false); } try { _Ping = new Timer(); _Ping.Interval = 1000; _Ping.Elapsed += Ping; _Ping.Start(); } catch (Exception e) { Log.Error("RpcClient", "Erreur :" + e.ToString()); } return(true); }
public bool Connect() { try { WellKnownClientTypeEntry CoRemote = new WellKnownClientTypeEntry(typeof(RpcConnector), "tcp://" + _Ip + ":" + _Port + "/" + typeof(RpcConnector).Name + _Key); if (_Channel == null) { _Channel = new TcpChannel(); ChannelServices.RegisterChannel(_Channel, false); RemotingConfiguration.RegisterWellKnownClientType(CoRemote); } Log.Info("Connect", "Registering connector : " + CoRemote.ObjectUrl); Connector = (RpcConnector)Activator.GetObject(CoRemote.ObjectType, CoRemote.ObjectUrl); _Id = Connector.Connect(_Name); Log.Success("RpcClient", "Connected to : " + _Ip + ":" + _Port); Load(); } catch (Exception e) { Log.Error("RcpClient", "Can not connect to : " + _Ip + ":" + _Port); Log.Error("RpcClient", "Erreur = " + e.ToString()); try { ChannelServices.UnregisterChannel(_Channel); } catch (Exception) { } _Channel = null; return false; } try { _Ping = new Timer(); _Ping.Interval = 1000; _Ping.Elapsed += Ping; _Ping.Start(); } catch (Exception e) { Log.Error("RpcClient", "Erreur :" + e.ToString()); } return true; }