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().
I think the current API is best as to accept the connection the subprotocol, and extensions should be considered. Whereas the response is very clear for Ping and CloseConnection events.
Of three events that require "trivial" response,
Request
,CloseConnection
, andPing
, two implementresponse()
, but one,Request
, does not. If it did hadresponse()
method that returnsAcceptConnection()
, event processing workflow could be simpler than it has to be now:but as it is in the version 1.0.0, we have to have an extra
elif
for theRequest
case, that always sendsAcceptConnection()
.