private void OnConnectionStatus_callback(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { if (null != OnConnectionStatus) { OnConnectionStatus(this, new OnConnectionStatusEventArgs(status, ref userLogin, size1)); } }
public BaseApi(string path) : this() { LibPath = path; Server = new ServerInfoField(); User = new UserInfoField(); UserLogin = new RspUserLoginField(); }
void OnConnectionStatus(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { if (size1 > 0) { Console.WriteLine("333333" + status); Console.WriteLine("333333" + userLogin.ToFormattedStringLong()); } else { Console.WriteLine("333333" + status); } }
public void Connect(ServerInfoField server, UserInfoField user) { if (_api == IntPtr.Zero) { _api = _proxy.XRequest(RequestType.Create); _proxy.XRequest(RequestType.Register, _api, IntPtr.Zero, 0, 0, Marshal.GetFunctionPointerForDelegate(_callback), 0, IntPtr.Zero, 0, IntPtr.Zero, 0); Server = server; User = user; UserLogin = null; _proxy.XRequest(RequestType.Connect, _api, IntPtr.Zero, 0, 0, new UnmanagedPtr <ServerInfoField>(server), 0, new UnmanagedPtr <UserInfoField>(User), 0, Marshal.StringToHGlobalAnsi(Path.GetTempPath()), 0); } }
private void OnConnectionStatus_callback(object sender, XAPI.ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { RspUserLoginClass cls = null; if (size1 > 0) { cls = new RspUserLoginClass(); RspUserLoginField field = userLogin; cls.TradingDay = field.TradingDay; cls.LoginTime = field.LoginTime; cls.SessionID = field.SessionID; cls.UserID = field.UserID; cls.AccountID = field.AccountID; cls.InvestorName = field.InvestorName(); cls.XErrorID = field.XErrorID; cls.RawErrorID = field.RawErrorID; cls.Text = field.Text(); } if (null == OnConnectionStatus) { QueueData qd = new QueueData(); qd.Type = (int)ResponeType.OnConnectionStatus; qd.Type_String = Enum <XAPI.ResponeType> .ToString(ResponeType.OnConnectionStatus); qd.Sender = this; qd.Data1 = status; qd.Data2 = Enum <XAPI.ConnectionStatus> .ToString(status); qd.Data3 = cls; qd.Data4 = size1; MessageQueue.Enqueue(qd); } else { OnConnectionStatus(this, (int)status, Enum <XAPI.ConnectionStatus> .ToString(status), ref cls, size1); } }
private void ProcessConnectionStatus(ref ResponseData data) { var status = (ConnectionStatus)data.Double1; switch (status) { case ConnectionStatus.Disconnected: case ConnectionStatus.Uninitialized: Connected = false; break; case ConnectionStatus.Done: Connected = true; Resubscribe(); break; } if (data.Size1 > 0) { var field = PInvokeUtility.PtrToStruct <InternalRspUserLoginField>(data.Ptr1); UserLogin = new RspUserLoginField(field); } _spi.ProcessConnectionStatus(status, UserLogin); }
private void _onConnectionStatus(object sender, XAPI.ConnectionStatus brokerStatus, ref RspUserLoginField userLogin, int size1) { FreeQuant.Framework.ConnectionStatus status = ConvertUtil.ConvertConnectionStatus(brokerStatus); mOnStatusChanged?.Invoke(status); // //if (brokerStatus == XAPI.ConnectionStatus.Done) { // Resub(); //} // LogUtil.SysLog("行情状态:" + brokerStatus.ToString()); }
private static void OnRspUserLogin(RspUserLoginField RspUserLogin, RspInfoField RspInfo, int RequestID, bool IsLast) { }
protected override void OnConnectionStatus(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { base.OnConnectionStatus(sender, status, ref userLogin, size1); // 修改成只处理最后一个,因为一般情况下,最后一个其它事件也是最后到来 if (sender == XApiList.Last()) { // 由于配置中肯定会设置多个行情连接,所有 if (status == ConnectionStatus.Logined) { TradingDay = userLogin.TradingDay; SaveAsTradingDay(); if (null != KdbWriter) { KdbWriter.SetTradingDay(TradingDay); } } else if (status == ConnectionStatus.Disconnected) { // 断开连接,可加入一接断开连接时的保存指令,由于连接数多,5秒之内不重复保存 if (null != KdbWriter) { Log.Info("OnConnectionStatus 中被动进行保存"); KdbWriter.Save(TradingDay); } } } }
protected override void OnConnectionStatus(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { base.OnConnectionStatus(sender, status, ref userLogin, size1); if (status == ConnectionStatus.Logined) { TradingDay = userLogin.TradingDay; SaveAsTradingDay(); } }
private void OnConnectionStatus_callback(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { if (null != OnConnectionStatus) { OnConnectionStatus(this, new OnConnectionStatusEventArgs(status, ref userLogin, size1)); } }
private static void OnRspUserLogin(RspUserLoginField RspUserLogin, RspInfoField RspInfo, int RequestID, bool IsLast) { _mdapi.SubscribeMarketData(new[] { "rb2109" }, 1); }
private void OnConnectionStatus_Disconnected(object sender, ConnectionStatus status, ref RspUserLoginField userLogin) { if (IsConnected) { //以前连接过,现在断了次线,要等重连 base.Status = ProviderStatus.Connecting; } else { //从来没有连接成功过,可能是密码错误,直接退出 //不能在线程中停止线程,这样会导致软件关闭进程不退出 //_Disconnect(); base.Status = ProviderStatus.Disconnected; } }
private void _OnConnectionStatus(double double1, IntPtr ptr1, int size1) { ConnectionStatus status = (ConnectionStatus)double1; // 连接状态更新 IsConnected = (ConnectionStatus.Done == status); RspUserLoginField obj = default(RspUserLoginField); switch(status) { case ConnectionStatus.Logined: case ConnectionStatus.Disconnected: case ConnectionStatus.Doing: obj = PInvokeUtility.GetObjectFromIntPtr<RspUserLoginField>(ptr1); UserLoginField = obj; break; default: break; } if (OnConnectionStatus != null) OnConnectionStatus(this, status, ref obj, size1); }
public OnConnectionStatusEventArgs(ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { this.status = status; this.userLogin = userLogin; this.size1 = size1; }
/// <summary> /// OnConnectionStatus回调 /// </summary> /// <param name="sender"></param> /// <param name="status"></param> /// <param name="userLogin"></param> /// <param name="size1"></param> private void OnConnectionStatus(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { showInfo("showing info inside onConnectionStatus now"); showInfo("//" + status + userLogin.ErrorMsg()); }
private void OnConnectionStatus_callback(object sender, XAPI.ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { RspUserLoginClass cls = null; if (size1 > 0) { cls = new RspUserLoginClass(); RspUserLoginField field = userLogin; cls.TradingDay = field.TradingDay; cls.LoginTime = field.LoginTime; cls.SessionID = field.SessionID; cls.UserID = field.UserID; cls.AccountID = field.AccountID; cls.InvestorName = field.InvestorName(); cls.XErrorID = field.XErrorID; cls.RawErrorID = field.RawErrorID; cls.Text = field.Text(); } if (null == OnConnectionStatus) { QueueData qd = new QueueData(); qd.Type = (int)ResponeType.OnConnectionStatus; qd.Type_String = Enum<XAPI.ResponeType>.ToString(ResponeType.OnConnectionStatus); qd.Sender = this; qd.Data1 = status; qd.Data2 = Enum<XAPI.ConnectionStatus>.ToString(status); qd.Data3 = cls; qd.Data4 = size1; MessageQueue.Enqueue(qd); } else { OnConnectionStatus(this, (int)status, Enum<XAPI.ConnectionStatus>.ToString(status), ref cls, size1); } }
protected virtual void OnStatusChanged(object sender, ConnectionStatus status, RspUserLoginField field) { logger.Info(status); if (field != null && status == ConnectionStatus.Logined) { logger.Info(field.RawErrorID != 0 ? field.RawErrorMsg() : field.DebugInfo()); } switch (status) { case ConnectionStatus.Done: if (field != null) { TradingDay = field.TradingDay(); OrderIdBase = int.Parse(field.Text); } OnConnected(); break; case ConnectionStatus.Disconnected: OnDisconnected(); break; } }
private void _OnConnectionStatus(double double1, IntPtr ptr1, int size1) { ConnectionStatus status = (ConnectionStatus)double1; // 连接状态更新 // 这种写法是为了解决多账号登录时,先进行Done然后再Logining或Doing的问题 if (ConnectionStatus.Disconnected == status || ConnectionStatus.Uninitialized == status) { IsConnected = false; } else if (ConnectionStatus.Done == status) { IsConnected = true; } RspUserLoginField obj = default(RspUserLoginField); if(size1>0) { obj = PInvokeUtility.GetObjectFromIntPtr<RspUserLoginField>(ptr1); UserLoginField = obj; } if (OnConnectionStatus_ != null) OnConnectionStatus_(this, status, ref obj, size1); }
public OnConnectionStatusEventArgs(ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { this.status = status; this.userLogin = userLogin; this.size1 = size1; }
private void OnConnectionStatus_Disconnected(object sender, ConnectionStatus status, ref RspUserLoginField userLogin) { /* * 1.连接失败 * 2.连接成功,登录失败 * 3.主动断开连接 * 4.被动断开,需要重连 */ switch (base.Status) { case ProviderStatus.Connected: // 以前连接成功了,现在需要试着重连 base.Status = ProviderStatus.Connecting; break; case ProviderStatus.Connecting: //xlog.Info("看是否会转成此状态"); break; case ProviderStatus.Disconnected: break; case ProviderStatus.Disconnecting: break; } }
protected virtual void OnStatusChanged(object sender, ConnectionStatus status, RspUserLoginField field) { Logger.Info(status); if (field != null && status == ConnectionStatus.Logined) { Logger.Info(field.RawErrorID != 0 ? field.RawErrorMsg() : field.DebugInfo()); } switch (status) { case ConnectionStatus.Done: if (field != null) { TradingDay = field.TradingDay(); if (string.IsNullOrEmpty(field.SessionID)) { OrderPrefix = string.Empty; } else { OrderPrefix = field.SessionID.EndsWith(":") ? field.SessionID : field.SessionID + ":"; } OrderIdBase = int.Parse(field.Text); } OnConnected(); break; case ConnectionStatus.Disconnected: OnDisconnected(); break; } }
protected virtual void OnConnectionStatus(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { if (size1 > 0) { if (userLogin.RawErrorID != 0) { (sender as XApi).Log.Info("{0}:{1}", status, userLogin.ToFormattedStringShort()); } else { (sender as XApi).Log.Info("{0}:{1}", status, userLogin.ToFormattedStringLong()); } } else { (sender as XApi).Log.Info("{0}", status); } if (status == ConnectionStatus.Logined) { TradingDay = userLogin.TradingDay; } }
private void OnConnectionStatus_callback(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { //lock(this) { // 断线重连的功能,可能正好与连接上的时间在同一时点,所以想法重新计时 _Timer.Enabled = false; if (size1 > 0) { if (userLogin.RawErrorID != 0) { (sender as XApi).GetLog().Info("{0}:{1}", status, userLogin.ToFormattedStringShort()); } else { (sender as XApi).GetLog().Info("{0}:{1}", status, userLogin.ToFormattedStringLong()); } } else { (sender as XApi).GetLog().Info("{0}", status); } switch (status) { case ConnectionStatus.Done: OnConnectionStatus_Done(sender, status); break; case ConnectionStatus.Disconnected: OnConnectionStatus_Disconnected(sender, status, ref userLogin); break; } _Timer.Enabled = true; } }