cloud_link.py 文件源码

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

项目:Parlay 作者: PromenadeSoftware 项目源码 文件源码
def connect_to_cloud_channel(self):
        """
        Connect up to the cloud channel with UUID uuid
        :param uuid: the UUID of this device. The uuid determines which channel you are connected to
        :return:
        """
        if self.uuid is None or self.uuid == "":
            raise RuntimeError("Must have a valid UUID to connect to the cloud")

        if self.connected_to_cloud:
            raise RuntimeError("Already Connected to cloud")

        yield self.get_channel()
        # cool, now set up the websocket connection to that channel
        reactor = self._adapter.reactor

        print "attempting to connect to", self.channel_uri
        self.cloud_factory = CloudLinkWebsocketClientFactory(self, self.channel_uri,  reactor=reactor)
        self.cloud_factory.protocol = CloudLinkWebsocketClient
        self.cloud_factory.continueTrying = True  # attempt to reconnect

        if self.channel_uri.startswith("wss"):
            reactor.connectSSL(self.cloud_factory.host, self.cloud_factory.port, self.cloud_factory, ssl.ClientContextFactory())
        else:
            reactor.connectTCP(self.cloud_factory.host, self.cloud_factory.port, self.cloud_factory)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号