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

Feat/websocket #6

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Feat/websocket #6

wants to merge 11 commits into from

Conversation

thgh
Copy link

@thgh thgh commented Jul 14, 2023

Basic websocket support

Relevant diff: 580c8be

Resolves #5

@CLAassistant
Copy link

CLAassistant commented Nov 23, 2023

CLA assistant check
All committers have signed the CLA.

@curiousercreative
Copy link

@thgh just noticing that this PR awaits your signing of the CLA to move forward.

@thgh
Copy link
Author

thgh commented Feb 11, 2024

I will look into it if @robbie-cahill reacts to this PR.

@@ -1,4 +1,3 @@

Copy link
Owner

Choose a reason for hiding this comment

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

Not sure if this change is intended?

Copy link
Author

Choose a reason for hiding this comment

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

Those are related to prettier formatting.

Here is the websocket commit: 580c8be

Copy link
Owner

Choose a reason for hiding this comment

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

i'll try and get this commit running locally, if it works we might be able to cherry pick it

app.ts Show resolved Hide resolved

let config = toml.parse(fs.readFileSync('config-instance.toml').toString());
// Read config from environment variables
Copy link
Owner

Choose a reason for hiding this comment

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

Reading config from environment variable is something i'd like to do but it would require some extra work for myself in the production environment. At this stage i'm deploying to a DigitalOcean droplet (Linux VM) without docker, so this may be easier using dotenv .env files.

// Override config with config.toml
// TODO: consider env vars over config.toml
try {
Copy link
Owner

@robbie-cahill robbie-cahill Feb 13, 2024

Choose a reason for hiding this comment

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

I think in this case .env files (using something like dotenv ) provide the best of both worlds of config files and env var based config.

Its a file that can be used/changed locally without a container, but then in a container they can just be ignored and the env vars injected by the container. This would be a single solution without overrides.

clientId: string;
websocket: HostipWebSocket;
sockets?: Map<string, HostipWebSocket>;
Copy link
Owner

Choose a reason for hiding this comment

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

Interesting, so the websocket connections get stored in this new map?

Copy link
Author

Choose a reason for hiding this comment

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

Yep, so there are X remote websocket connections to the server, a single connection between client/server, and X local websocket connections. The string in this map identifies each remote websocket, this information is included in each message so it gets delivered to the correct local websocket.

One thing that doesn't work reliably is closed sockets: some remote errors cannot be replayed locally, error 1006 I think.

@robbie-cahill
Copy link
Owner

robbie-cahill commented Feb 13, 2024

@thgh the PR looks good, I like the websocket implementation. But I think the files where only formatting is changed are probably are not needed.

I like the idea of using environment variables over .toml config files, but I think a good way to do this would be to use .env files which are files that inject environment variables That way we get the best of both worlds, a config file that can be modified as needed, but in a containerised/docker environment the .env could just be empty and the container can just inject these.

Also the CLA would need to be signed before I can merge anything (edit: looks like you've already done that, so all good on that front).

@thgh
Copy link
Author

thgh commented Feb 13, 2024

This PR is quite massive, it's probably best to review per commit and cherrypick what looks best to you. Here is a handy button:
Screenshot 2024-02-13 at 11 53 27

I started with a commit that only does prettier formatting to reduce clutter in the later commits. (as I didn't want to turn off automatic formatting)

@junket
Copy link

junket commented Jun 17, 2024

It would be great to get this merged. @thgh's fork is solid! Thanks guys!!

@BanDroid
Copy link

BanDroid commented Jul 1, 2024

is this feature gonna be merged?

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.

WebSocket support
6 participants