MCPcopy Create free account
hub / github.com/ElementsProject/lightning / BinWebSocket

Class BinWebSocket

tests/test_connection.py:3945–3960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3943
3944 # Adapter to turn websocket into a stream "connection"
3945 class BinWebSocket(object):
3946 def __init__(self, hostname, port):
3947 self.ws = websocket.WebSocket()
3948 self.ws.connect("ws://" + hostname + ":" + str(port))
3949 self.recvbuf = bytes()
3950
3951 def send(self, data):
3952 self.ws.send(data, websocket.ABNF.OPCODE_BINARY)
3953
3954 def recv(self, maxlen):
3955 while len(self.recvbuf) < maxlen:
3956 self.recvbuf += self.ws.recv()
3957
3958 ret = self.recvbuf[:maxlen]
3959 self.recvbuf = self.recvbuf[maxlen:]
3960 return ret
3961
3962 ws = BinWebSocket('localhost', ws_port)
3963 lconn = wire.LightningConnection(ws,

Callers 1

test_websocketFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_websocketFunction · 0.68