public static void Init(Action <string> OnNotifyInfo) { var utaConfig = CommonUtils.GetConfig("UAT"); if (string.IsNullOrEmpty(utaConfig) || !Regex.IsMatch(utaConfig, "[0-9A-Za-z.]+:[0-9]+")) { CommonUtils.Log("IMS配置异常,UTA未配置"); return; } string[] ipPort = utaConfig.Split(':'); string ip = ipPort[0]; ushort port = Convert.ToUInt16(ipPort[1]); StringBuilder ErrInfo = new StringBuilder(256); //1.打开PB while (!IsOpened) { IsOpened = ImsPbClient_Open(ErrInfo); if (!IsOpened) { CommonUtils.Log("Ims Open Fail, try login 1 second later"); Thread.Sleep(1000); } } //2.设置通知函数 ac = new NotifyKnockInfoDelegate(OnNotifyInfo); GC.KeepAlive(ac); try { //3.连接服务器 bool isConnected = ImsPbClient_Connect(ip, port, ErrInfo); if (!isConnected) { CommonUtils.Log("ImsApi.ImsPbClient_Connect Error {0}", ErrInfo.ToString()); return; } } catch (Exception ex) { CommonUtils.Log(" IMS API Init Exception, {0}", ex.Message); } }
public static extern void ImsPbClient_SetNotifyKnockInfoFunc(NotifyKnockInfoDelegate NotifyKnockInfoFunc);