public virtual void init_RemoteInterface() { try { r_host_comm = (I_HC_Comm)RemoteBuilder.GetRemoteObj(typeof(I_HC_Comm), RemoteBuilder.getRemoteUri(RemoteBuilder.getHostIP(), (int)RemotingPortEnum.HOST, "Comm")); } catch(Exception ex) { ConsoleServer.WriteLine(ex.Message);} RemoteInterface.ServerFactory.SetChannelPort(remotePort); ServerFactory.RegisterRemoteObject(regRemoteType, regRemoteName); ConsoleServer.Start(consolePort); }
static void Main(string[] args) { rhostobj = (I_HC_Comm)RemoteBuilder.GetRemoteObj(typeof(I_HC_Comm), RemoteBuilder.getRemoteUri(RemoteBuilder.getHostIP(), (int)RemotingPortEnum.HOST, "Comm")); if (!System.IO.Directory.Exists(timccexchg.Settings1.Default.OneMinVDCurrPath)) System.IO.Directory.CreateDirectory(timccexchg.Settings1.Default.OneMinVDCurrPath); if (!System.IO.Directory.Exists(timccexchg.Settings1.Default.FiveMinVDCurrPath)) System.IO.Directory.CreateDirectory(timccexchg.Settings1.Default.FiveMinVDCurrPath); if (!System.IO.Directory.Exists(timccexchg.Settings1.Default.OneMinVDHistPath)) System.IO.Directory.CreateDirectory(timccexchg.Settings1.Default.OneMinVDHistPath); if (!System.IO.Directory.Exists(timccexchg.Settings1.Default.FiveMinVDHistPath)) System.IO.Directory.CreateDirectory(timccexchg.Settings1.Default.FiveMinVDHistPath); if (!System.IO.Directory.Exists(timccexchg.Settings1.Default.EpConfCurrPath)) System.IO.Directory.CreateDirectory(timccexchg.Settings1.Default.EpConfCurrPath); if (!System.IO.Directory.Exists(timccexchg.Settings1.Default.CommCurrPath)) System.IO.Directory.CreateDirectory(timccexchg.Settings1.Default.CommCurrPath); init_tmr(); setDateTimeFromHost(); tmr1hour_Elapsed(null, null); while(true) System.Threading.Thread.Sleep(1000 * 60); }
void tmr1min_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (isInTmr) return; try { isInTmr = true; if (r_host_comm == null) return; ((RemoteClassBase)r_host_comm).HelloWorld(); } catch { r_host_comm = null; new System.Threading.Thread(RemoteObjectConnectTask).Start(); } finally { isInTmr = false; } }
void RemoteObjectConnectTask() { if (IsInRemoteObjectConnectTask) return; IsInRemoteObjectConnectTask = true; while (true) { try { r_host_comm = (I_HC_Comm)RemoteBuilder.GetRemoteObj(typeof(I_HC_Comm), RemoteBuilder.getRemoteUri(RemoteBuilder.getHostIP(), (int)RemotingPortEnum.HOST, "Comm")); if (r_host_comm != null) { ConsoleServer.WriteLine( "hostrobj connected"); break; } System.Threading.Thread.Sleep(5000); ConsoleServer.WriteLine(mfccid + "host robj reconnecting!"); } catch { ; } } IsInRemoteObjectConnectTask=false; }
void Connect_Remote_Host_Comm_Task(object robj) { while (true) { try { if (r_host_comm == null) { r_host_comm = (I_HC_Comm)RemoteBuilder.GetRemoteObj(typeof(I_HC_Comm), RemoteBuilder.getRemoteUri(RemoteBuilder.getHostIP(), (int)RemotingPortEnum.HOST, "Comm")); if (r_host_comm != null) { ConsoleServer.WriteLine("r_host_comm" + " connected!"); return; } else ConsoleServer.WriteLine("reconnect host remoteObject failed..reconnecting!"); } } catch { ConsoleServer.WriteLine("reconnect host remoteObject failed..reconnecting!"); } System.Threading.Thread.Sleep(10000); } }
public virtual void init_RemoteInterface() { // mark 2012-7-26 try { r_host_comm = (I_HC_Comm)RemoteBuilder.GetRemoteObj(typeof(I_HC_Comm), RemoteBuilder.getRemoteUri(RemoteBuilder.getHostIP(), (int)RemotingPortEnum.HOST, "Comm")); if (r_host_comm == null) new System.Threading.Thread(RemoteObjectConnectTask).Start(); } catch (Exception ex) { ConsoleServer.WriteLine(ex.Message + ex.StackTrace); } try { RemoteInterface.ServerFactory.SetChannelPort(remotePort); ServerFactory.RegisterRemoteObject(regRemoteType, regRemoteName); ConsoleServer.WriteLine("RemotePort Listen at " + remotePort); } catch (Exception ex) { ConsoleServer.WriteLine(ex.Message + ex.StackTrace); } ConsoleServer.Start(consolePort); }
void tmr1min_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //throw new Exception("The method or operation is not implemented."); if (isInTmr) return; try { isInTmr = true; if (r_host_comm == null) return; ((RemoteClassBase)r_host_comm).HelloWorld(); } catch { r_host_comm = null; new System.Threading.Thread(RemoteObjectConnectTask).Start(); } finally { isInTmr = false; } }