Example #1
0
    async def check_user_login_status(self):
        if not self.user_cookie:
            self._user_login_status = False
            self._user_id = random_user_id()
            return

        try:
            res = await self.session.get(r'http://{host}:{port}/{uri}'.format(
                host=API_LIVE_BASE_URL, port=80, uri=CHECK_USER_LOGIN_URI))
            data = await res.json()
            if data['msg'] == 'ok':
                logger.info(
                    '{user_name} 登录成功'.format(user_name=data['data']['uname']))
                user_info = await self.get_user_info()
                self._user_id = user_info['userInfo']['uid']
        except Exception as e:
            logger.exception(e)
Example #2
0
 async def send_join_room(self):
     await self.send_socket_data(action=JOIN_CHANNEL,
                                 payload=json.dumps({
                                     'uid': random_user_id(),
                                     'roomid': self.room_id
                                 }))