Exemple #1
0
    def _send_init_connect_sync(self):
        kargs = {
            'client_ver': int(SysConfig.get_client_ver()),
            'client_id': str(SysConfig.get_client_id()),
            'recv_notify': True,
            'is_encrypt': self.is_encrypt(),
            'push_proto_fmt': SysConfig.get_proto_fmt()
        }

        ret, msg, req_str = InitConnect.pack_req(**kargs)
        if ret == RET_OK:
            _, send_result = self._net_mgr.send(self._conn_id, req_str, True)
        else:
            logger.error('Fail to pack InitConnect')
            return ret

        send_result.wait()
        if send_result.err is PacketErr.Ok:
            ret, msg, conn_info = self._handle_init_connect_rsp(
                send_result.rsp)
            if ret == RET_OK:
                # logger.info('InitConnect ok: {}'.format(conn_info))
                logger.info(
                    'InitConnect ok: conn_id={}, host={}, port={}, user_id={}'.
                    format(self._conn_id, self.__host, self.__port,
                           conn_info['login_user_id']))
                return RET_OK

        if msg == '':
            msg = send_result.msg if send_result.msg != '' else str(
                send_result.err)
        logger.warning('InitConnect fail: {}'.format(msg))
        return RET_ERROR
Exemple #2
0
    def on_connected(self, conn_id):
        logger.info('Connected : conn_id={0}; '.format(conn_id))
        kargs = {
            'client_ver': int(SysConfig.get_client_ver()),
            'client_id': str(SysConfig.get_client_id()),
            'recv_notify': True,
        }

        ret, msg, req_str = InitConnect.pack_req(**kargs)
        if ret == RET_OK:
            ret, msg = self._net_mgr.send(conn_id, req_str)
        else:
            logger.warning(FTLog.make_log_msg('InitConnect.pack_req fail', msg=msg))

        if ret != RET_OK:
            with self._lock:
                self._sync_req_ret = _SyncReqRet(ret, msg)
Exemple #3
0
    def on_connected(self, conn_id):
        logger.info('Connected : conn_id={0}; '.format(conn_id))
        kargs = {
            'client_ver': int(SysConfig.get_client_ver()),
            'client_id': str(SysConfig.get_client_id()),
            'recv_notify': True,
            'is_encrypt': self.is_encrypt(),
            'push_proto_fmt': SysConfig.get_proto_fmt()
        }

        ret, msg, req_str = InitConnect.pack_req(**kargs)
        if ret == RET_OK:
            ret, msg = self._net_mgr.send(conn_id, req_str)
        else:
            logger.warning(FTLog.make_log_msg('InitConnect.pack_req fail', msg=msg))

        if ret != RET_OK:
            with self._lock:
                self._sync_req_ret = _SyncReqRet(RET_ERROR, msg)
                self._connect_err = Err.RsaErr
            self.close()