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

Add support for logout a client #297

Closed
wants to merge 1 commit into from

Conversation

rollandf
Copy link
Contributor

@rollandf rollandf commented Mar 28, 2018

issue #296
First commit with backend support

@rollandf rollandf requested review from nirs and sleviim March 28, 2018 14:36
def client_bye(self):
log.info('client received "bye" message.')
reactor.stop()
os._exit(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys.exit() is the proper way to exit. os._exit() needed only in special cases.

But I think that reactor.stop() should be enough to make the client terminate - see line 78.

data = str(msg)
for client in self.clients:
if isinstance(client, PlayerProtocol):
if client.name == name:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be little nicer to do:

if client.name == name and isinstance(client, PlayerProtocol):
    client.send_message(data)

Would be even nicer if we avoid checking the type of the client. Do we enforce unique client name for all clients?

@@ -192,4 +199,11 @@ def render_POST(self, request):
except ValueError:
request.setResponseCode(http.BAD_REQUEST)
return b"Invalid rate value %r, expected number" % value
if "bye" in request.args:
name = request.args["bye"][0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POST is used to change server state. I think we need different API to disconnect clients. Maybe:

DELETE /players/name

@rollandf rollandf closed this Jan 10, 2022
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

Successfully merging this pull request may close these issues.

3 participants