mirror of
https://github.com/google/bumble.git
synced 2026-04-16 00:25:31 +00:00
Upgrade websockets dependency to 15.0.1+
This commit is contained in:
@@ -20,7 +20,7 @@ import json
|
||||
import struct
|
||||
import sys
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.logging
|
||||
from bumble import data_types
|
||||
@@ -367,7 +367,7 @@ async def keyboard_device(device, command):
|
||||
|
||||
if command == 'web':
|
||||
# Start a Websocket server to receive events from a web page
|
||||
async def serve(websocket, _path):
|
||||
async def serve(websocket: websockets.asyncio.server.ServerConnection):
|
||||
while True:
|
||||
try:
|
||||
message = await websocket.recv()
|
||||
@@ -398,7 +398,7 @@ async def keyboard_device(device, command):
|
||||
pass
|
||||
|
||||
# pylint: disable-next=no-member
|
||||
await websockets.serve(serve, 'localhost', 8989)
|
||||
await websockets.asyncio.server.serve(serve, 'localhost', 8989)
|
||||
await asyncio.get_event_loop().create_future()
|
||||
else:
|
||||
message = bytes('hello', 'ascii')
|
||||
|
||||
@@ -20,7 +20,7 @@ import logging
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.logging
|
||||
from bumble import data_types, decoder, gatt
|
||||
@@ -29,12 +29,11 @@ from bumble.device import AdvertisingParameters, Device
|
||||
from bumble.profiles import asha
|
||||
from bumble.transport import open_transport
|
||||
|
||||
ws_connection: Optional[websockets.WebSocketServerProtocol] = None
|
||||
ws_connection: Optional[websockets.asyncio.server.ServerConnection] = None
|
||||
g722_decoder = decoder.G722Decoder()
|
||||
|
||||
|
||||
async def ws_server(ws_client: websockets.WebSocketServerProtocol, path: str):
|
||||
del path
|
||||
async def ws_server(ws_client: websockets.asyncio.server.ServerConnection):
|
||||
global ws_connection
|
||||
ws_connection = ws_client
|
||||
|
||||
@@ -100,7 +99,7 @@ async def main() -> None:
|
||||
),
|
||||
)
|
||||
|
||||
await websockets.serve(ws_server, port=8888)
|
||||
await websockets.asyncio.server.serve(ws_server, port=8888)
|
||||
|
||||
await hci_transport.source.terminated
|
||||
|
||||
|
||||
@@ -21,8 +21,9 @@ import asyncio
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.logging
|
||||
from bumble import a2dp, avc, avdtp, avrcp, utils
|
||||
@@ -217,6 +218,8 @@ def on_avrcp_start(avrcp_protocol: avrcp.Protocol, websocket_server: WebSocketSe
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
class WebSocketServer:
|
||||
socket: Optional[websockets.asyncio.server.ServerConnection]
|
||||
|
||||
def __init__(
|
||||
self, avrcp_protocol: avrcp.Protocol, avrcp_delegate: Delegate
|
||||
) -> None:
|
||||
@@ -227,9 +230,9 @@ class WebSocketServer:
|
||||
|
||||
async def start(self) -> None:
|
||||
# pylint: disable-next=no-member
|
||||
await websockets.serve(self.serve, 'localhost', 8989) # type: ignore
|
||||
await websockets.asyncio.server.serve(self.serve, 'localhost', 8989) # type: ignore
|
||||
|
||||
async def serve(self, socket, _path) -> None:
|
||||
async def serve(self, socket: websockets.asyncio.server.ServerConnection) -> None:
|
||||
print('### WebSocket connected')
|
||||
self.socket = socket
|
||||
while True:
|
||||
|
||||
@@ -22,7 +22,7 @@ import logging
|
||||
import sys
|
||||
from typing import Iterable, Optional
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.core
|
||||
import bumble.logging
|
||||
@@ -33,7 +33,7 @@ from bumble.transport import open_transport
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
ws: Optional[websockets.WebSocketServerProtocol] = None
|
||||
ws: Optional[websockets.asyncio.server.ServerConnection] = None
|
||||
ag_protocol: Optional[hfp.AgProtocol] = None
|
||||
source_file: Optional[io.BufferedReader] = None
|
||||
|
||||
@@ -114,8 +114,7 @@ def on_hfp_state_change(connected: bool):
|
||||
send_message(type='hfp_state_change', connected=connected)
|
||||
|
||||
|
||||
async def ws_server(ws_client: websockets.WebSocketServerProtocol, path: str):
|
||||
del path
|
||||
async def ws_server(ws_client: websockets.asyncio.server.ServerConnection):
|
||||
global ws
|
||||
ws = ws_client
|
||||
|
||||
@@ -273,7 +272,7 @@ async def main() -> None:
|
||||
|
||||
on_dlc(session)
|
||||
|
||||
await websockets.serve(ws_server, port=8888)
|
||||
await websockets.asyncio.server.serve(ws_server, port=8888)
|
||||
|
||||
if len(sys.argv) >= 5:
|
||||
global source_file
|
||||
|
||||
@@ -22,7 +22,7 @@ import json
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.logging
|
||||
from bumble import hci, hfp, rfcomm
|
||||
@@ -30,7 +30,7 @@ from bumble.device import Connection, Device
|
||||
from bumble.hfp import HfProtocol
|
||||
from bumble.transport import open_transport
|
||||
|
||||
ws: Optional[websockets.WebSocketServerProtocol] = None
|
||||
ws: Optional[websockets.asyncio.server.ServerConnection] = None
|
||||
hf_protocol: Optional[HfProtocol] = None
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ async def main() -> None:
|
||||
await device.set_connectable(True)
|
||||
|
||||
# Start the UI websocket server to offer a few buttons and input boxes
|
||||
async def serve(websocket: websockets.WebSocketServerProtocol, _path):
|
||||
async def serve(websocket: websockets.asyncio.server.ServerConnection):
|
||||
global ws
|
||||
ws = websocket
|
||||
async for message in websocket:
|
||||
@@ -166,7 +166,7 @@ async def main() -> None:
|
||||
response = str(await hf_protocol.query_current_calls())
|
||||
await websocket.send(response)
|
||||
|
||||
await websockets.serve(serve, 'localhost', 8989)
|
||||
await websockets.asyncio.server.serve(serve, 'localhost', 8989)
|
||||
|
||||
await hci_transport.source.wait_for_termination()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import json
|
||||
import struct
|
||||
import sys
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.logging
|
||||
from bumble.core import (
|
||||
@@ -425,7 +425,7 @@ deviceData = DeviceData()
|
||||
async def keyboard_device(hid_device: HID_Device):
|
||||
|
||||
# Start a Websocket server to receive events from a web page
|
||||
async def serve(websocket, _path):
|
||||
async def serve(websocket: websockets.asyncio.server.ServerConnection):
|
||||
global deviceData
|
||||
while True:
|
||||
try:
|
||||
@@ -476,7 +476,7 @@ async def keyboard_device(hid_device: HID_Device):
|
||||
pass
|
||||
|
||||
# pylint: disable-next=no-member
|
||||
await websockets.serve(serve, 'localhost', 8989)
|
||||
await websockets.asyncio.server.serve(serve, 'localhost', 8989)
|
||||
await asyncio.get_event_loop().create_future()
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import json
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.logging
|
||||
from bumble import data_types
|
||||
@@ -101,7 +101,7 @@ async def main() -> None:
|
||||
)
|
||||
device.add_service(AudioStreamControlService(device, sink_ase_id=[1]))
|
||||
|
||||
ws: Optional[websockets.WebSocketServerProtocol] = None
|
||||
ws: Optional[websockets.asyncio.server.ServerConnection] = None
|
||||
mcp: Optional[MediaControlServiceProxy] = None
|
||||
|
||||
advertising_data = bytes(
|
||||
@@ -162,7 +162,7 @@ async def main() -> None:
|
||||
|
||||
device.on('connection', on_connection)
|
||||
|
||||
async def serve(websocket: websockets.WebSocketServerProtocol, _path):
|
||||
async def serve(websocket: websockets.asyncio.server.ServerConnection):
|
||||
nonlocal ws
|
||||
ws = websocket
|
||||
async for message in websocket:
|
||||
@@ -173,7 +173,7 @@ async def main() -> None:
|
||||
)
|
||||
ws = None
|
||||
|
||||
await websockets.serve(serve, 'localhost', 8989)
|
||||
await websockets.asyncio.server.serve(serve, 'localhost', 8989)
|
||||
|
||||
await hci_transport.source.terminated
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import secrets
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import websockets
|
||||
import websockets.asyncio.server
|
||||
|
||||
import bumble.logging
|
||||
from bumble import data_types
|
||||
@@ -110,7 +110,7 @@ async def main() -> None:
|
||||
vcs = VolumeControlService()
|
||||
device.add_service(vcs)
|
||||
|
||||
ws: Optional[websockets.WebSocketServerProtocol] = None
|
||||
ws: Optional[websockets.asyncio.server.ServerConnection] = None
|
||||
|
||||
def on_volume_state_change():
|
||||
if ws:
|
||||
@@ -152,7 +152,7 @@ async def main() -> None:
|
||||
advertising_data=advertising_data,
|
||||
)
|
||||
|
||||
async def serve(websocket: websockets.WebSocketServerProtocol, _path):
|
||||
async def serve(websocket: websockets.asyncio.server.ServerConnection):
|
||||
nonlocal ws
|
||||
await websocket.send(
|
||||
dumps_volume_state(vcs.volume_setting, vcs.muted, vcs.change_counter)
|
||||
@@ -166,7 +166,7 @@ async def main() -> None:
|
||||
await device.notify_subscribers(vcs.volume_state)
|
||||
ws = None
|
||||
|
||||
await websockets.serve(serve, 'localhost', 8989)
|
||||
await websockets.asyncio.server.serve(serve, 'localhost', 8989)
|
||||
|
||||
await hci_transport.source.terminated
|
||||
|
||||
|
||||
Reference in New Issue
Block a user