sides / war3observer

A Warcraft III observer API reader/renderer for streaming overlays
MIT License
51 stars 20 forks source link

2 pc setup #4

Closed Sega01 closed 4 years ago

Sega01 commented 4 years ago

Hi,

I have a question. I have a two pc setup, one pc for the game/observer and the other for OBS. What things I have to change to get the informations from one pc to the other?

Greetings!

sides commented 4 years ago

Hey,

This is something I unfortunately neglected a little. Connecting to localhost is pretty hardcoded in the client. If you want a quick fix, there is something you can do:

  1. Copy paste one of the HTML files in the client folder, the one you want to use.

  2. Open it and add the following code before the call to app.boot() (at line 12):

    app.connect = function(tries) {
    this._ws = new WebSocket(`ws://{REPLACE WITH GAME PC IP}:${this._wsPort}/`);
    this._ws.onmessage = this.onmessage.bind(this);
    
    if (tries > 0) {
    this._ws.onclose = e => e.code !== 1000 && setTimeout(() => this.connect(tries - 1), 5000);
    this._ws.onopen = e => this._ws.onclose = z => z.code !== 1000 && setTimeout(() => this.connect(this._wsReconnectTries), 5000);
    }
    }

    This just replaces the connect method of the app with a carbon copy of itself except it connects to a different IP address instead of localhost. You can also edit the port there.

  3. Use this HTML file in OBS instead of the included ones while running the server on the game pc.

Let me know if anything is unclear or if it doesn't work. I'm not an expert.


If you are interested in a better solution, there are many things that could be done. The easiest would be to make the IP address a member of App, so copy+pasting HTML files is more straightforward. I think it would also be possible to set up JSONP or something to actually fetch a config.js that users could put their port/ip address in.

Sega01 commented 4 years ago

Hi, sorry for the late response. I tried your way but I cant get a connection from the game pc to the streaming pc.

As an error I get this in the dev console: 1v1-overview.html:13 WebSocket connection to 'ws://192.168.XX.XX:8657/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

The second thing I noticed when starting a local network game with two bots and me as the observer I just get the information from one player. On the other side I see my own stats which are, ofc, just zeros.

I would try to try your other solution with the IP adress as a member but I dont have any idea how to do it.

sides commented 4 years ago

I think, at that point, it's probably a network thing. Is the port open on the game pc?

The second thing I noticed when starting a local network game with two bots and me as the observer I just get the information from one player. On the other side I see my own stats which are, ofc, just zeros.

This is strange. I never tested this on LAN games, so could be anything. It could always be a problem with bots, though. Please let me know if it happens in a real game.

I would try to try your other solution with the IP adress as a member but I dont have any idea how to do it.

No worries, was half meant as a mental note to myself. If you're fine with the instructions I posted before, it's no issue.

Sega01 commented 4 years ago

I think, at that point, it's probably a network thing. Is the port open on the game pc?

Hi, yes. The port is even open at both pcs. Could be there any other kind of problem?

sides commented 4 years ago

The port is correct? (You are running war3observer.exe with --port=8657 or config file?) I noticed you are not using the default one. Is the server the only thing running on that port? Is the ip address correct?

Otherwise, I would try messing more with your firewall rules, making sure absolutely everything is open. Maybe it's a router thing?

Sega01 commented 4 years ago

Yea, I run the overlay with the config file. I also have the original 1on1 overview.html on my gamer pc running to see if theres the overlay. Maybe its really the IP. I will try it today on another 2 pc setup.

sides commented 4 years ago

There might be an issue in code, maybe the server needs to be set to listen on the local IP address specifically instead of localhost. It's currently not possible to change it with a config entry but would be easy to add.

Could you clone the repo, change localhost on this line to the IP address you're using, run it python -m war3observer --port=8657, and see if that works? If so I'll make it a config entry. I just didn't think it mattered for the server.

Sega01 commented 4 years ago

Yes, that it! It works now (besides that i just see only one bot and my own zero statistics, but that is because of the bots?)! I have to test it with two real player in a local network game still.

sides commented 4 years ago

I've pushed a commit to make configuring host/port easier for both the server and client. The client still requires copy+pasting html files, but I think it's an okay of a solution for something like this.

Bots can mess up the overlay if you are running non-English Warcraft III. If you are running an English Warcraft III this may be an issue with LAN games. Please let me know how it goes.

If you confirm everything is working I will publish a release with these changes.

Sega01 commented 4 years ago

After some days I have some news: Everything is working fine, the "ressource problem" was because of the LAN game. When I tried a battle.net game everything was displaying right, even with bots. Just a question, that doesnt have something to do with that previous problems: Is there a way to display the overlay on top of the game without OBS? For example like in this project https://github.com/osztenkurden/CS-GO-Observer-Custom-HUD ? In theory we would "just" need an tool that display the overlay without the background, so everything besides the elements is clickable.

sides commented 4 years ago

Hi, sorry for the late response.

I'm a little disappointed LAN games aren't working, I'll hold the release until after I check out if I can fix that. I'm assuming you have a setup that works though and don't need it, but I'll make a post on this issue when I do make a release with new instructions on the new simpler method of 2 pc setup.

Is there a way to display the overlay on top of the game without OBS?

No, but rendering webpages outside of browsers is quite standard these days. You can probably look up an easy way of doing this, like a quick electron program. You should be able to control how it displays, like no borders, always on top, etc.

sides commented 4 years ago

@Sega01 I've fixed LAN games, was actually a significant bug that I've seen happen in normal games as well. So with that I've also made a release, below this comment I'll write new instructions if you want to update it.

sides commented 4 years ago

For a 2 pc setup:

  1. Create a war3observer.config.json file in the same folder as war3observer.exe with these contents:

    {
    "host": "{GAME PC IP}"
    }
  2. Copy paste one of the HTML files in the client folder, the one you want to use.

  3. Open it and add the following code before the call to app.boot() (at line 12):

    app.host = '{GAME PC IP}';
  4. Use this HTML file in OBS instead of the included ones while running the server on the game pc.

Make sure port 8124 is not being blocked by your game pc's firewall. If you need to change the port, it's the same thing but with port instead of host.