Esempio n. 1
0
    def _handle_init_connect(self, conn_id, proto_info, ret, msg, rsp_pb):
        data = None
        if ret == RET_OK:
            ret, msg, data = InitConnect.unpack_rsp(rsp_pb)

        with self._lock:
            self._sync_req_ret = _SyncReqRet(ret, msg)
            if ret == RET_OK:
                conn_info = copy(data)
                conn_info['is_encrypt'] = self.is_encrypt()
                self._sync_conn_id = conn_info['conn_id']
                self._keep_alive_interval = conn_info[
                    'keep_alive_interval'] * 4 / 5
                self._net_mgr.set_conn_info(conn_id, conn_info)
                self._last_keep_alive_time = datetime.now()
                FutuConnMng.add_conn(conn_info)
                logger.info(
                    FTLog.make_log_msg("InitConnect ok",
                                       conn_id=conn_id,
                                       info=conn_info))
            else:
                logger.warning(FTLog.make_log_msg("InitConnect error",
                                                  msg=msg))
                self._connect_err = msg
                self.close()
Esempio n. 2
0
    def _handle_init_connect_rsp(self, rsp):
        ret, msg, data = InitConnect.unpack_rsp(rsp)
        if ret != RET_OK:
            return ret, msg, None

        with self._lock:
            conn_info = copy(data)
            conn_info['is_encrypt'] = self.is_encrypt()
            self._sync_conn_id = conn_info['conn_id']
            self._keep_alive_interval = conn_info['keep_alive_interval'] * 4 / 5
            self._net_mgr.set_conn_info(self._conn_id, conn_info)
            now = datetime.now()
            self._last_keep_alive_time = now
            self._last_recv_time = now
            self._status = ContextStatus.READY
            FutuConnMng.add_conn(conn_info)
        return ret, '', conn_info