Web插座 - 我可以在使用socket.connect()方法连接到服务器时发送有关客户端的额外信息
我正在从事WEBRTC项目,并且具有输入视频流的客户端,将显示输入流和服务器的客户端。我正在使用WEBRTC和WebSockets。每个客户端都连接到信号服务器。我想知道服务器如何知道连接的客户端是否是输入视频流的客户端,或者是将显示一些流的客户端。在将客户端连接到服务器的那一刻,我可以发送一些额外的信息吗?客户端用python的JavaScript和服务器编写。也许我可以在socket.connect()方法中使用一些参数?
服务器处理连接:
@sio.event
async def connect(sid, environ):
print('Connected', sid)
sessionIDs.append(sid)
await sio.emit('ready', room=ROOM, skip_sid=sid)
sio.enter_room(sid, ROOM)
将客户端连接到服务器:
socket.connect();
I am working on webrtc project and I have client(s) with input video stream, client that will show input stream and server. I am using webrtc and websockets. Every client is connected to signaling server. I want to know how server can know if connected client is client with input video stream or it is client that will show some streams. Can I send some extra info in the moment of connecting client side to server? Client is written in Javascript and server in Python. Maybe I can use some parameters in socket.connect() method?
Server handling connecting:
@sio.event
async def connect(sid, environ):
print('Connected', sid)
sessionIDs.append(sid)
await sio.emit('ready', room=ROOM, skip_sid=sid)
sio.enter_room(sid, ROOM)
Connecting client to server:
socket.connect();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在WebSocket URL中添加数据作为获取参数,或使用其他路径。
在 server 以获取它们:
Just add your data as GET parameter in the websocket url, or use a differente path.
And on the server to get them: