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 linux port #135

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Add linux port #135

wants to merge 15 commits into from

Conversation

jthistle
Copy link

So, I sort of went and ported this to Linux... it seems to work pretty well.

The one thing that doesn't work is the 'commands' route on the web server - I'm not sure what that's meant to do, maybe you could give some advice @Koenvh1 ? :)

This is based on v3.1.0, but I have to PR into a branch rather than a tag, so master it is then. It may work with master, I haven't tested it.

Work-in-progress.

@jthistle jthistle changed the title initial linux port Add linux port Mar 20, 2021
@Koenvh1
Copy link
Owner

Koenvh1 commented Mar 20, 2021

The "official" server window has a couple of options, e.g. it detects which game is running (ETS2 or ATS), determines the language (en-GB, nl-NL, he-IL, etc.), and supports global keyboard/controller bindings for e.g. changing the volume and station. To pass these settings to the browser, the browser polls the server for "commands"* and checks for differences (this is what the id is for, can be as simple as a timestamp of change or hash of the object). If there is a difference, it executes the action, changes the language, and switches between ATS and ETS2 (if there is a difference).

* Originally it just passed the keyboard presses to control the playback, thus the name commands

@Koenvh1
Copy link
Owner

Koenvh1 commented Mar 20, 2021

https://github.com/Koenvh1/ets2-local-radio/blob/master/server/ETS2%20Local%20Radio%20desktop/Commands.cs

That's what the commands object looks like.

What the action and amount look like is something you can find in the function named writeFile (I believe because it used to write an actual JSON file to disk) here
https://github.com/Koenvh1/ets2-local-radio/blob/master/server/ETS2%20Local%20Radio%20desktop/Main.cs#L516

Just search for writeFile in that class, and you can see what it is called with.

@jthistle
Copy link
Author

That's great, thanks for the help.

@jthistle
Copy link
Author

So, this is pretty much working minus the feature to use commands, allthough it feeds the commands route the data it expects to prevent errors. I do need to write some more docs for it though, and probably add some better installation / setup scripts.

Up to you @Koenvh1 whether you want to merge this or not once that's done, do let me know what you think :)

@Koenvh1
Copy link
Owner

Koenvh1 commented Mar 20, 2021

I will test it (and so will a couple of other people who I know have asked for a Linux version before), and if it works, then I don't see why not. The only thing I am not sure about are the JavaScript additions, but that's something I would have to look into.

@jthistle
Copy link
Author

jthistle commented Mar 20, 2021

Sure, I can remove that if you want. I just wanted to see if I could make it so that when I turned the engine off, the radio would also stop (immersion!)

Rest of that sounds good, thanks for feedback on this :)

@Koenvh1
Copy link
Owner

Koenvh1 commented Mar 23, 2021

Are you sure that your read_line keeps working? Someone had issues where it would work initially, but break after some time (and no longer switched stations when crossing a border)

@jthistle
Copy link
Author

That's possible. I may need to add something to catch if the read_util dies or the pipe breaks, and to restart it if that happens.

@jthistle
Copy link
Author

@Koenvh1 I've made some improvements to how errors are handled. Let me know if that helps.

@Remyrios
Copy link

Okay so I'm the mystical person that has asked for a linux version before. Pulled the latest commit and the one main issue still persists. The stations don't automatically switch when crossing a border nor do they start playing when you first open up the app/website. Also after the commit it's screaming at me with this error:

Traceback (most recent call last):
  File "/usr/lib/python3.9/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.9/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.9/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/kaperios/Games/ETS2 Local Radio/linux/server/main.py", line 59, in __init__
    super().__init__(*args, directory="../../web/")
  File "/usr/lib/python3.9/http/server.py", line 653, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/lib/python3.9/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/lib/python3.9/http/server.py", line 427, in handle
    self.handle_one_request()
  File "/usr/lib/python3.9/http/server.py", line 415, in handle_one_request
    method()
  File "/home/kaperios/Games/ETS2 Local Radio/linux/server/main.py", line 102, in do_GET
    super().do_GET()
  File "/usr/lib/python3.9/http/server.py", line 660, in do_GET
    self.copyfile(f, self.wfile)
  File "/usr/lib/python3.9/http/server.py", line 859, in copyfile
    shutil.copyfileobj(source, outputfile)
  File "/usr/lib/python3.9/shutil.py", line 208, in copyfileobj
    fdst_write(buf)
  File "/usr/lib/python3.9/socketserver.py", line 799, in write
    self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe

@jthistle
Copy link
Author

@Kaperios I see, thanks for testing it out. I think I know how to fix that one, and I'll look into the border crossing thing - I imagine I need to send the correct command. I'll ping you again once I've tried to sort it.

@jthistle
Copy link
Author

@Kaperios what is the expected behaviour when first opening the website? Which station do you expect to start playing automatically? I'm asking because I can't test this in Windows. Thanks.

@jthistle
Copy link
Author

@Kaperios @Koenvh1 Hi, I think I've fixed it now. Please give it a go and let me know if it works!

@Lezurex
Copy link

Lezurex commented Aug 11, 2021

I recently found out about this ETS2 plugin, unfortunately, there was no official Linux release. I found this PR here, pulled the latest commit, built it and tried it out for a couple of hours. It works really well. Had no problems so far.

I'd love to see this as an official release soon!

@jthistle
Copy link
Author

Good to hear - unfortunately comms went dark after my last comment in this PR. I too would like to see this merged if possible :)

@Koenvh1
Copy link
Owner

Koenvh1 commented Aug 12, 2021

The thing is that I do not have a computer to test it on currently, hence I asked @Kaperios to test it for me. If he experiences issues, then probably something needs fixing.

@jthistle
Copy link
Author

@Koenvh1 I understand, it's just that after the issues were reported I fixed them and said so, but I didn't recieve any further communication after that.

@Koenvh1
Copy link
Owner

Koenvh1 commented Aug 15, 2021

I have added a link to here on the releases page. Just as a heads-up, I am planning a version 4 which will lead to some breaking changes.

@Koenvh1
Copy link
Owner

Koenvh1 commented Aug 23, 2021

I released the beta version of 3.3, which serves a lot of files locally again due to some policy changes with Google Chrome. I would recommend checking whether your Linux version supports that as well, otherwise it will stop working with starting from Chrome 93 (due to be released on 31 August).

@jthistle
Copy link
Author

I made only one insignificant change to the web part of the code, so it should be fine, I would think.

@Koenvh1 Koenvh1 mentioned this pull request Oct 13, 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.

4 participants