pinylib.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:pinylib-rtc 作者: nortxort 项目源码 文件源码
def connect(self):
        """ Initialize a websocket handshake. """
        tc_header = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0',
            'Accept-Language': 'en-US,en;q=0.5',
            'Accept-Encoding': 'gzip, deflate, br',
            'Sec-WebSocket-Protocol': 'tc',
            'Sec-WebSocket-Extensions': 'permessage-deflate'
        }

        # Comment out next 2 lines to not
        # have debug info from websocket show in console.
        if config.DEBUG_MODE:
            websocket.enableTrace(True)

        self._ws = websocket.create_connection(
            'wss://wss.tinychat.com',
            header=tc_header,
            origin='https://tinychat.com'
        )

        if self._ws.connected:
            log.info('connecting to: %s' % self.room_name)
            if self.send_join_msg():
                self.is_connected = True
                self.__callback()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号