async def connect(): ws = Websocket("http://localhost:8080/ws") msg = await ws.get() robotDescription = await conn.getLocalDescription(msg) ws.put_nowait(robotDescription) print("Started WebRTC") await ws.close()
async def connect(): ws = Websocket("https://82796db29997.ngrok.io/InventoTest12") remoteDescription = await ws.get() robotDescription = await conn.getLocalDescription(remoteDescription) ws.put_nowait(robotDescription) print("Started WebRTC") await ws.close()
async def wsping(request): ws = Websocket(request) print("Got websocket") await ws.onReady() print("WS READY") while ws.ready: print("MSG") ws.put_nowait(await ws.get()) print("DONE") return
async def connect(): # ws = Websocket("http://localhost:8080/ws") # ws = Websocket("https://rtcbot.dev/myRandomSequence1532") # ws = Websocket("http://13.127.250.133:8080/ws") # ws = Websocket("http://localhost:8080/xyz") # xyz could be the remote device id, in multi_client mode. ws = Websocket("http://13.127.250.133:1452/xyz001") remoteDescription = await ws.get() robotDescription = await conn.getLocalDescription(remoteDescription) ws.put_nowait(robotDescription) print("Started WebRTC") await ws.close()
async def connect(): channel = sys.argv[1] if len(sys.argv) > 1 else "default" print("Starting WebRTC, channel=" + channel) ws = Websocket("https://rtc.imjoy.io/ws/" + channel) print("Waiting for remote connection") remoteDescription = await ws.get() print("Sending local description") robotDescription = await conn.getLocalDescription(remoteDescription) ws.put_nowait(robotDescription) print("Started WebRTC") await ws.close() print("WebRTC connected")
async def connect(self): ws = Websocket("http://localhost:8080/xyz") remoteDescription = await ws.get() print("The remote description is of type: " + str(type(remoteDescription)) + "\n") robotDescription = await self.conn.getLocalDescription( remoteDescription) print("The robot description is of type: " + str(type(robotDescription)) + "\n") ws.put_nowait(robotDescription) print("Started WebRTC") await ws.close()
async def websocket(request): global ws ws = Websocket(request) print("Robot Connected") await ws # Wait until the websocket closes print("Robot disconnected") return ws.ws
async def connect(): ws = Websocket("https://rtcbot.dev/test1") await ws.onReady() if ws.error is not None: print("Had error", ws.error) return remoteDescription = await ws.get() print("Received Description") myDescription = await conn.getLocalDescription(remoteDescription) ws.put_nowait(myDescription) await ws.close() print("Closed socket") await conn.onReady() if conn.error is not None: print("Had conn error", conn.error) print("\n\n\nConnection ready!\n\n\n") conn.put_nowait("Hello!")
async def websocket(request): global robotWebSocket if robotWebSocket is not None: c = robotWebSocket.close() if c is not None: await c robotWebSocket = Websocket(request) print("{:%Y-%m-%d %H:%M:%S}: Robot Connected".format( datetime.datetime.now())) await robotWebSocket # Wait until the websocket closes print("{:%Y-%m-%d %H:%M:%S}: Robot Disconnected".format( datetime.datetime.now()))
async def websocket(request): """ Remote microscope connection """ global ws temp_ws = Websocket(request) name_ws = await temp_ws.get() print("Robot Connected") ws[name_ws] = temp_ws await ws[name_ws] # Wait until the websocket closes del ws[name_ws] print("Robot disconnected") return temp_ws.ws
async def registerOnServerAndAwaitRtcConnections(): print("sending /registerRobot") ws = Websocket(REMOTE_WEB_SERVER + '/registerRobot') while True: remoteDescription = await ws.get() print("{:%Y-%m-%d %H:%M:%S}: new web user requested connect".format(datetime.datetime.now())) connection = RTCConnection() connection.video.putSubscription(videoFrameSubscription) connection.subscribe(onMessage) connection.putSubscription(cv2ColorSubscription) connection.put_nowait({ "action": "hsv", "hsv": hsv }) @connection.onClose def close(): print("{:%Y-%m-%d %H:%M:%S}: Connection Closed".format(datetime.datetime.now())) connections.remove(connection) connections.append(connection) robotDescription = await connection.getLocalDescription(remoteDescription) ws.put_nowait(robotDescription)
async def wsKey(request): global ws_List key = request.match_info['key'] print(key) ##Check if key already exist in ws_List socket = Websocket(request) ws_Dic = {"key": key, "socket": socket} ws_List.append(ws_Dic) print(socket) print("Robot Connected") await socket print(socket) print("Robot disconnected") ##Delete ws_Dic form ws_List ws_List = deleteList(ws_List, key) return socket.ws
async def test_websocket(aiohttp_client, aiohttp_unused_port): port = aiohttp_unused_port() client = await aiohttp_client(create_ws_server, server_kwargs={"port": port}) ws = Websocket("http://localhost:{}/".format(port)) ws.put_nowait("Hello") assert await ws.get() == "Hello" ws.put_nowait({"foo": "bar"}) resp = await ws.get() assert "foo" in resp assert resp["foo"] == "bar" s = ws.onClose() await ws.close() await s await asyncio.sleep(0.1)
async def connect(): """ Connect establishes a websocket connection to the server, and uses it to send and receive info to establish webRTC connection. """ # Read configuration to get device name with open('../device_config.txt') as json_file: device_name = json.load(json_file)["device_name"] # Establish web socket connection and send device name ws = Websocket("http://178.154.227.116:8080/ws") # !!! CHANGE FOR REAL IP ws.put_nowait(device_name) # Establish WebRTC connection remoteDescription = await ws.get() robotDescription = await conn.getLocalDescription(remoteDescription) ws.put_nowait(robotDescription) print("Started WebRTC") await ws.close()