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 ability to set nicknames for individual subscribers #19

Merged
merged 5 commits into from Mar 27, 2023
Merged

Conversation

ff14wed
Copy link
Owner

@ff14wed ff14wed commented Mar 27, 2023

This PR allows Subscribers to optionally specify a nickname.

For example, setting a nickname like follows:

Payload { OP: OP.Debug, CHANNEL: 9000, DATA: u8"TEST_CLIENT" }

will result in a response:

Payload { OP: OP.Debug, CHANNEL: 9000, CHANGED NICKNAME: TEST_CLIENT (subscriber 0) }

and log messages will contain the subscriber nickname like so:

[INFO] New subscriber connected: 0
[INFO] Filter set for TEST_CLIENT (subscriber 0): 0b11111111
[INFO] Disconnected: TEST_CLIENT (subscriber 0)
[INFO] Shutting down server because last subscriber disconnected

These are the restrictions on the values of nickname that are accepted:

  • The bytes in DATA must be valid UTF-8.
  • Must contain only ASCII alphanumeric characters or underscores (^[A-Za-z0-9_]+$)
  • Must be 30 characters or less
  • Names are allowed to be the same as other subscribers.

This is so that it is easier to tell when the runtime is stuck
(acquiring the loader lock) during shutdown.
Also moved some things around in the server code to somewhat
improve readability.
@ff14wed ff14wed merged commit 0722c98 into main Mar 27, 2023
4 checks passed
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.

None yet

1 participant