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

Setting up a local version for testing #4

Open
adamxfort opened this issue Mar 13, 2019 · 4 comments
Open

Setting up a local version for testing #4

adamxfort opened this issue Mar 13, 2019 · 4 comments

Comments

@adamxfort
Copy link

HI,
I would like to set up a local version of the website using python http.server or some other option. However, with node.js running and everything else in place I'm getting errors

:formatted:461 POST http://localhost:7800/api/getgames2 501 (Unsupported method ('POST'))
sendJSON @ :formatted:461
(anonymous) @ :formatted:878
d @ :formatted:346
(anonymous) @ :formatted:369
setTimeout (async)
p @ :formatted:368
(anonymous) @ :formatted:773
(anonymous) @ :formatted:900
:formatted:812 could not load: http://localhost:7800/api/getgames2
b @ :formatted:812
a @ :formatted:432
l @ :formatted:453
load (async)
sendJSON @ :formatted:457
(anonymous) @ :formatted:878
d @ :formatted:346
(anonymous) @ :formatted:369
setTimeout (async)
p @ :formatted:368
(anonymous) @ :formatted:773
(anonymous) @ :formatted:900

I was wondering what could be the issue, where should I point the server to or if it's even possible to run a local version of the website.
I want a local version just to test it and I don't have acess to the server it is going to run on in the future yet.

Thanks.

@greggman
Copy link
Owner

greggman commented Mar 13, 2019

It's not clear to me what you're trying to do.

On the same machine for testing?

It's possible to run a local server. Unfortunately how you set it up depends your needs. It's networking so there's literally an infinite number of setups

I guess the first thing to do is clone this repo and run it

  • install node.js
  • clone this repo git clone https://github.com/greggman/happyfuntimes.net.git
  • cd into folder cd happyfuntimes.net
  • install deps npm install
  • run it npm start

It should print something like

$ npm start

> happyfuntimes.net@0.0.3 start /Users/gregg/src/happyfuntimes.net
> node server.js

{"port":1337,"address":"::ffff:127.0.0.1","level":"info","message":"started listening: "}

Then in another terminal on the same machine try to talk to it

with

curl -X POST http://localhost:1337/api/status

when I try it I get

$ curl -X POST http://localhost:1337/api/status
{"gameCache":{"numGames":0}}%   

do you?

Also your game is written in Unity or what?

@adamxfort
Copy link
Author

Yes, that's exactly what I'm trying to do, run the website on the same machine as the game. So I can test it before I get access to the actual server.
The game is in Unity yes.
So I got all of this working the website runs fine and everything returns the same things as you've mentioned. However, even with the game running and being able to connect to it using happyfuntimes.net with my local website it won't connect. Is there anything else that needs to or should be done?
Thanks.

@greggman
Copy link
Owner

So, in the game, in whatever object you put the PlayerSpawner script you need to set rendezvousURL to

http://localhost:1337/api/inform2

Then run the game.

Then in a browser ON THE SAME MACHINE go to

http://localhost:1337/

If you want to connect from a phone you need to stop the server and run it like this (mac/linux)

HFT_ADDRESS=0.0.0.0 npm start

or Windows

set HFT_ADDRESS=0.0.0.0
npm start

Then you need to look up the ip address of your computer (mine is 192.168.1.94). On my phone I type http://192.168.1.94:1337

As for running it with your own domain name you'll need to register a domain.

If you use heroku someone has already done it here

#3 (comment)

@adamxfort
Copy link
Author

adamxfort commented Mar 13, 2019

Amazing, it works like a charm! Hopefully setting up the server later is going to be without any issues. Thanks a lot, I really appreciate it :)

Edit: Only one small thing, I can't get the phone to actually connect to the game but the website runs fine on it.

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

No branches or pull requests

2 participants