Skip to content

Websockets #257

Answered by gi0baro
josejachuf asked this question in Q&A
Discussion options

You must be logged in to vote

@josejachuf sorry for the delay, I was a little busy in the last days.

BTW, here is how I implemented it, but please consider that sockets get used only to get new messages in real time, since for posting new messages I think a standard POST request is better. Also, this is implemented using redis since it saves quite a lot of coding.

First, you need an async implementation of redis (based on aioredis package):

from aioredis import Redis as _Redis
from aioredis.pool import ConnectionsPool
from contextlib import asynccontextmanager
from emmett.extensions import Extension, listen_signal

class Redis(Extension):
    def on_load(self):
        self.pool = None

    @listen_signal('after_loop')

Replies: 9 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by gi0baro
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #257 on December 11, 2020 16:15.