public void on_login_resp(login_resp data) { Invoke((MethodInvoker) delegate { if (data.success != 0) { MessageBox.Show("登陆失败:" + data.ErrorMsg); return; } if (data.symbol != comb_Instrument.Text) { MessageBox.Show("登陆失败:服务器返回symbol与前端symbol不一致"); return; } common.CompareVersion(); order_easy.Show(); ZMQControl.Instance().heart_beat_timer_start(); order_easy.start_sub_recv(comb_product.Text, comb_Instrument.Text); order_easy.start_data_init(data); saveConfig(); order_easy.operation_log("登陆成功 " + " 子帐号:" + comb_account.Text + " 合约:" + comb_Instrument.Text + " tip:" + this.current_tick + " Server:" + common.AccountDic[comb_account.Text].sertverIp + ":" + common.AccountDic[comb_account.Text].ipPort); this.Hide(); }); }
void sktDealer_ReceiveReady(object sender, SocketEventArgs e) { string more = e.Socket.Receive(Encoding.UTF8); string msgtype = e.Socket.Receive(Encoding.UTF8); if (!e.Socket.ReceiveMore) { if (msgtype == MessageType.OE_HEARTBEAT) { Program.log.Debug("recv heartbeat"); lastHeartBeatTime = Environment.TickCount; } return; } byte[] revBytes = new byte[1024 * 256]; int revSize = e.Socket.Receive(revBytes); MemoryStream revParam = new MemoryStream(revBytes, 0, revSize); revParam.Seek(0, SeekOrigin.Begin); try { if (msgtype == MessageType.OE_LOGIN_RESP) { login_resp data = new login_resp(); data = Serializer.Deserialize <login_resp>(revParam); this.logForm.on_login_resp(data); return; } if (msgtype == MessageType.OE_ORDER_RESP) { order_resp data = new order_resp(); data = Serializer.Deserialize <order_resp>(revParam); this.sim.on_order_resp_handle(data); return; } if (msgtype == MessageType.OE_ORDER_RESP_ERR) { order_resp_err data = new order_resp_err(); data = Serializer.Deserialize <order_resp_err>(revParam); this.sim.on_order_resp_err_handle(data); return; } if (msgtype == MessageType.OE_CANCEL_RESP) { cancel_resp data = new cancel_resp(); data = Serializer.Deserialize <cancel_resp>(revParam); Program.log.Info("OE_CANCEL_RESP,local_ref;" + data.local_ref + " order_ref:" + data.order_ref); return; } if (msgtype == MessageType.OE_CANCEL_RESP_ERR) { cancel_resp_err data = new cancel_resp_err(); data = Serializer.Deserialize <cancel_resp_err>(revParam); this.sim.on_cancel_resp_err_handle(data); return; } if (msgtype == MessageType.OE_DELET_RTN) { delete_rtn data = new delete_rtn(); data = Serializer.Deserialize <delete_rtn>(revParam); this.sim.on_delete_rtn_handle(data); return; } if (msgtype == MessageType.OE_POS_RTN) { pos_rtn data = new pos_rtn(); data = Serializer.Deserialize <pos_rtn>(revParam); this.sim.on_pos_rtn_handle(data); return; } if (msgtype == MessageType.OE_MESSAGE_RTN) { message_rtn data = new message_rtn(); data = Serializer.Deserialize <message_rtn>(revParam); this.sim.on_message_rtn_handle(data); return; } if (msgtype == MessageType.OE_FORCE_LOGOUT_RTN) { force_logout_rtn data = new force_logout_rtn(); data = Serializer.Deserialize <force_logout_rtn>(revParam); this.sim.on_force_logout_handle(data); return; } if (msgtype == MessageType.OE_LOGOUT_RESP) { return; } } catch (Exception ex) { Program.log.Error(ex, ex); } }