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

Tachyon connect #424

Merged
merged 13 commits into from
Aug 26, 2024
Merged

Conversation

geekingfrog
Copy link
Contributor

This is the code to allow players and autohosts to connect using tachyon.

Local testing

  1. there should be an oauth application as part of the task teiserver.fakedata. Otherwise create one through the admin interface
  2. generate a token:
mix teiserver.gen_token --user root  # can be any other user
  1. start the local server: mix phx.server
  2. connect with a websocket, I'm using websocat:
websocat ws://127.0.0.1:4000/tachyon --protocol v0.tachyon --header "Authorization: Bearer $TOKEN"
  1. send a test ping: "test_ping"

Overview

As usual, reviewing commit by commit should help. I am following the design doc. The main differences with the current way of doing things in teiserver are:

  • More nesting of the supersion trees. This help with encapsulation, making dependencies clearer, and mitigate one transient failure in one system taking down the entire server.
  • Use of registries for sending messages and listing/querying stuff. Registries automatically clean up when a registered process dies. They are also a foundation of any otp application so very much battle tested.
  • The disconnection handling is mostly there to lay the groundwork for parsing and validating tachyon messages and commands. This should be easier for new contributor to help.

@@ -1007,6 +1009,56 @@ defmodule Teiserver.CacheUser do
end
end

@spec tachyon_login(T.user(), String.t(), String.t()) ::
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mostly taken from login_from_token

"""
@callback handle_info(term(), term()) :: WebSock.handle_result()

# TODO: add other callbacks to handle (parsed) tachyon commands
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will come in a later PR

The current implementation would *always* persist the user, regardless
of the parameter passed in.
`get_user(nil, [])` works, but more by chance than anything, and it
doesn't quite make sense.
Check there's a valid oauth token.
Must provide the correct tachyon version during subprotocol negotiation
Starts with the registry for player connection. This will be expanded
later. The goal is to keep everything tachyon related together so that
it's easier to see the dependencies between processes and manage
initialisation of the components.
Not doing anything with them yet
Ensure that only the most recent connection is valid. Terminate existing
connection when a new one comes in.
The session can also track a player's state (connected/disconnected)
@geekingfrog geekingfrog force-pushed the tachyon-connect branch 2 times, most recently from 5aceec2 to 543daf7 Compare August 24, 2024 08:35
@geekingfrog geekingfrog marked this pull request as ready for review August 24, 2024 08:39
@L-e-x-o-n L-e-x-o-n merged commit 06330e1 into beyond-all-reason:master Aug 26, 2024
3 checks passed
@geekingfrog geekingfrog deleted the tachyon-connect branch August 31, 2024 16:29
geekingfrog added a commit to geekingfrog/teiserver that referenced this pull request Sep 11, 2024
Update tzdata lib
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.

2 participants