Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending Websocket messages to other clients #27

Closed
dmitrykrylov opened this issue Oct 18, 2016 · 2 comments
Closed

Sending Websocket messages to other clients #27

dmitrykrylov opened this issue Oct 18, 2016 · 2 comments

Comments

@dmitrykrylov
Copy link

I am only getting started with websockets and asyncio, that's why I will allow myself to ask for help with the next issue.

I am trying to implement webRTC video chat with aiopyramid and websockets on backend. My frontend exactly is like one in this article: link.
It connects with the view from docs:

@view_config(route_name='echo', mapper=WebsocketMapper)
@asyncio.coroutine
def echo(ws):
    while True:
        message = yield from ws.recv()
        if message is None:
            break
        yield from ws.send(message)

I expect that when I send description to the server I get it on another client. But when I have got gotDescription callback on a client, I get multiple gotIceCandidate callbacks and multiple messages yielded by the view while another client gets nothing.

Logs on the client:
1111111111111

@housleyjk
Copy link
Owner

Can you give me a link to the actual code? The link in that article doesn't go to code that matches the function definitions in the article, so I am wondering if there are discrepancies.

Also, the server in that article has a broadcast function, but the Aiopyramid code you sent me doesn't broadcast, it only responds to it's own client. In other words, your Python code isn't sharing messages with other clients. You need to write the equivalent of

wss.broadcast = function(data) {
    for(var i in this.clients) {
        this.clients[i].send(data);
    }
};

@dmitrykrylov
Copy link
Author

Thanks.
Creating a global list of websockets works for me. It's enough for getting started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants