/// <summary> /// 發送模組 /// </summary> /// <param name="dpscKey"></param> /// <param name="dpscIp"></param> /// <param name="dpscPort"></param> /// <param name="chkSum"></param> /// <param name="outputMessage"></param> /// <param name="broadcasting"></param> /// <param name="channel"></param> public ForwardModule(string dpscKey, string dpscIp, ushort dpscPort, uint chkSum, Action <string> outputMessage, Action <byte[], ushort> broadcasting, uint channel) { fOutputMessage = outputMessage; fBroadcasting = broadcasting; fChannel = channel; fDpsc = new Dpsc(dpscKey); fDpsc.ServerHost = dpscIp; fDpsc.ServerPort = dpscPort; fDpsc.SysCheckSum = chkSum; fDpsc.OnStatus += fDpsc_OnStatus; fDpsc.OnRcvData += fDpsc_OnRcvData; fDpsc.Connect(); }
/// <summary> /// Dpsc連線事件 /// </summary> /// <param name="sender"></param> /// <param name="status"></param> /// <param name="message"></param> private void fDpsc_OnStatus(Dpsc sender, Dpsc.DpscStatusList status, string message) { switch (status) { case Dpsc.DpscStatusList.DebugError: break; case Dpsc.DpscStatusList.Connecting: { fOutputMessage("Dpsc連線中"); } break; case Dpsc.DpscStatusList.Connected: { fOutputMessage("Dpsc連線成功"); //訂閱即時條件頻道 fDpsc.SubChannel(fChannel); } break; case Dpsc.DpscStatusList.KeepAlive: break; case Dpsc.DpscStatusList.SubChannel: { fOutputMessage(string.Format("訂閱{0}", message)); } break; case Dpsc.DpscStatusList.DisSubChannel: break; case Dpsc.DpscStatusList.ServerTime: break; case Dpsc.DpscStatusList.DisConnect: { fOutputMessage("Dpsc斷線了"); fDpsc.Connect(); } break; case Dpsc.DpscStatusList.ConnectTimeout: { fOutputMessage("Dpsc連線逾時"); fDpsc.Connect(); } break; case Dpsc.DpscStatusList.UserDisConnect: { fOutputMessage("使用者將Dpsc斷開"); } break; default: break; } }