当前位置: 首页>>代码示例>>Python>>正文


Python ABNF.OPCODE_BINARY属性代码示例

本文整理汇总了Python中websocket.ABNF.OPCODE_BINARY属性的典型用法代码示例。如果您正苦于以下问题:Python ABNF.OPCODE_BINARY属性的具体用法?Python ABNF.OPCODE_BINARY怎么用?Python ABNF.OPCODE_BINARY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在websocket.ABNF的用法示例。


在下文中一共展示了ABNF.OPCODE_BINARY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_channel

# 需要导入模块: from websocket import ABNF [as 别名]
# 或者: from websocket.ABNF import OPCODE_BINARY [as 别名]
def write_channel(self, channel, data):
        """Write data to a channel."""
        # check if we're writing binary data or not
        binary = six.PY3 and type(data) == six.binary_type
        opcode = ABNF.OPCODE_BINARY if binary else ABNF.OPCODE_TEXT

        channel_prefix = chr(channel)
        if binary:
            channel_prefix = six.binary_type(channel_prefix, "ascii")

        payload = channel_prefix + data
        self.sock.send(payload, opcode=opcode) 
开发者ID:kubernetes-client,项目名称:python-base,代码行数:14,代码来源:ws_client.py

示例2: update

# 需要导入模块: from websocket import ABNF [as 别名]
# 或者: from websocket.ABNF import OPCODE_BINARY [as 别名]
def update(self, timeout=0):
        """Update channel buffers with at most one complete frame of input."""
        if not self.is_open():
            return
        if not self.sock.connected:
            self._connected = False
            return
        r, _, _ = select.select(
            (self.sock.sock, ), (), (), timeout)
        if r:
            op_code, frame = self.sock.recv_data_frame(True)
            if op_code == ABNF.OPCODE_CLOSE:
                self._connected = False
                return
            elif op_code == ABNF.OPCODE_BINARY or op_code == ABNF.OPCODE_TEXT:
                data = frame.data
                if six.PY3:
                    data = data.decode("utf-8", "replace")
                if len(data) > 1:
                    channel = ord(data[0])
                    data = data[1:]
                    if data:
                        if channel in [STDOUT_CHANNEL, STDERR_CHANNEL]:
                            # keeping all messages in the order they received
                            # for non-blocking call.
                            self._all.write(data)
                        if channel not in self._channels:
                            self._channels[channel] = data
                        else:
                            self._channels[channel] += data 
开发者ID:kubernetes-client,项目名称:python-base,代码行数:32,代码来源:ws_client.py

示例3: _subscribe

# 需要导入模块: from websocket import ABNF [as 别名]
# 或者: from websocket.ABNF import OPCODE_BINARY [as 别名]
def _subscribe(self, ws, streams):
        msg = msgpack.dumps({
            'streams': streams,
        })
        ws.send(msg, opcode=ABNF.OPCODE_BINARY) 
开发者ID:alpacahq,项目名称:pymarketstore,代码行数:7,代码来源:stream.py

示例4: update

# 需要导入模块: from websocket import ABNF [as 别名]
# 或者: from websocket.ABNF import OPCODE_BINARY [as 别名]
def update(self, timeout=0):
        """Update channel buffers with at most one complete frame of input."""
        if not self.is_open():
            return
        if not self.sock.connected:
            self._connected = False
            return
        r, _, _ = select.select(
            (self.sock.sock, ), (), (), timeout)
        if r:
            op_code, frame = self.sock.recv_data_frame(True)
            if op_code == ABNF.OPCODE_CLOSE:
                self._connected = False
                return
            elif op_code == ABNF.OPCODE_BINARY or op_code == ABNF.OPCODE_TEXT:
                data = frame.data
                if six.PY3:
                    data = data.decode("utf-8")
                if len(data) > 1:
                    channel = ord(data[0])
                    data = data[1:]
                    if data:
                        if channel in [STDOUT_CHANNEL, STDERR_CHANNEL]:
                            # keeping all messages in the order they received for
                            # non-blocking call.
                            self._all += data
                        if channel not in self._channels:
                            self._channels[channel] = data
                        else:
                            self._channels[channel] += data 
开发者ID:aws-samples,项目名称:aws-kube-codesuite,代码行数:32,代码来源:ws_client.py


注:本文中的websocket.ABNF.OPCODE_BINARY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。