This repository was archived by the owner on Oct 26, 2019. It is now read-only.
Separate socket server from the HTTP API. #241
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this patch the HttpApi class no longer handles the socket server. Instead users have to instantiate it manually. This actually makes the API less weird; previously you had to pass a Node core HTTP server instance to the middleware creation function, essentially a circular dependency. Now you can add the middleware to the express server, then get the HTTP server instance from the express server and pass it to the socket server function.
All communication between the HTTP API and the socket server goes through Redis messages now. The only remaining thing to migrate was the temporary auth tokens the socket server uses; they were already stored in Redis but the authentication routes used API methods from the socket server object. Now the routes don't need access to the socket server object anymore.
It needs more work on the u-wave-core side, but this is one step to allowing the socket server to run in its own process. That would be real neat because we could do server updates (if the socket server was not changed, which is true a good chunk of the time) without everyone's chat connections dying :)