wsproto icon indicating copy to clipboard operation
wsproto copied to clipboard

feature request: implement `response()` method for `Request` event

Open crosser opened this issue 3 years ago • 0 comments

Of three events that require "trivial" response, Request, CloseConnection, and Ping, two implement response(), but one, Request, does not. If it did had response() method that returns AcceptConnection(), event processing workflow could be simpler than it has to be now:

for event in ws.events():
    if isinstance(event, (CloseConnection, Ping, Request)):
        write_data += ws.send(event.response())
    elif isinstance(event, TextMessage):
        # meningful processing

but as it is in the version 1.0.0, we have to have an extra elif for the Request case, that always sends AcceptConnection().

crosser avatar Jun 23 '22 22:06 crosser