public ConnectionCode Subscribe(LoginUser user, IUFXMessageHandlerFactory handlerFactory) { callback = new T2SubCallback(handlerFactory); subcribe = _conn.NewSubscriber(callback, SubscribeName, (int)_timeOut, 2000, 100); if (subcribe == null) { string msg = string.Format("主推业务订阅创建失败: {0}", _conn.GetMCLastError()); logger.Error(msg); return(ConnectionCode.ErrorFailSubscribe); } CT2SubscribeParamInterface args = new CT2SubscribeParamInterface(); args.SetTopicName("ufx_topic"); args.SetReplace(false); args.SetFilter("operator_no", user.Operator); CT2Packer req = new CT2Packer(2); req.BeginPack(); req.AddField("login_operator_no", Convert.ToSByte('S'), 16, 4); req.AddField("password", Convert.ToSByte('S'), 16, 4); req.AddStr(user.Operator); req.AddStr(user.Password); req.EndPack(); CT2UnPacker unpacker = null; int ret = subcribe.SubscribeTopicEx(args, 50000, out unpacker, req); req.Dispose(); //根据文档说明,返回值大于0表示有效的订阅标识,否则其他表示错误。 if (ret > 0) { string msg = string.Format("主推业务订阅创建成功, 返回码: {0}, 消息: {1}", ret, _conn.GetErrorMsg(ret)); logger.Info(msg); return(ConnectionCode.SuccessSubscribe); } else { string outMsg = string.Empty; if (unpacker != null) { //Show(back); DataParser parser = new DataParser(); parser.Parse(unpacker); unpacker.Dispose(); var errResponse = T2ErrorHandler.Handle(parser); outMsg = errResponse.MessageDetail; } string msg = string.Format("主推业务订阅创建失败,返回码: {0}, 消息: {1}, 返回数据包消息: {2}", ret, _conn.GetErrorMsg(ret), outMsg); logger.Error(msg); return(ConnectionCode.ErrorFailSubscribe); } }
public void Init(T2SDKWrap t2SDKWrap) { lock (_locker) { _loginBLL = new LoginSyncBLL(t2SDKWrap); _accountBLL = new AccountBLL(t2SDKWrap); _securityBLL = new SecurityBLL(t2SDKWrap); _querySyncBLL = new UFX.impl.QuerySyncBLL(t2SDKWrap); _withdrawSyncBLL = new UFX.impl.WithdrawSyncBLL(t2SDKWrap); _UFXMessageHandlerFactory = new UFXMessageHandlerFactory(); } }
private ConnectionCode Subscribe(LoginUser loginUser, IUFXMessageHandlerFactory handlerFactory) { return(UFXBLLManager.Instance.Subscriber.Subscribe(loginUser, handlerFactory)); }
public T2SubCallback(IUFXMessageHandlerFactory bllFactory) { _handlerFactory = bllFactory; }