Giter Club home page Giter Club logo

boardhousenet's Introduction

BoardhouseNet

This repo serves as a full-stack enviornment for the boardhouse game framework. The primary project goal is to add networking via websockets to boardhouse. Boardhouse is originally developed as a front-end game engine solution for browser based games. Setting up a client / server architecture would involve splitting up the existing front-end solution into two parts: client and server. Client will handle rendering game objects as well as sending messages to the server. Server will handle the lobby system, game engine logic and handling and sending messages back to the client. Hence why src is split up into gameclient, gameserver lobbyclient, and lobbyserver. If there were an easier way to bolt on a networking layer to boardhouse, I'd go that route, but currently this is the best solution I have come up with.


Build Instructions:

npm install
npm run build
cd dist
node lobby.js

Go to localhost:8080 to test it out. All production files will be contained in the dist folder.

More build scripts can be found in the package.json.

The project uses 4 different bundles: lobby server bundle, lobby client bundle, game server bundle, and game client bundle. The entry points for each bundle are as follows:

  • lobby.js (lobby server): src > lobbyserver > server.ts
  • lobby-client.bundle.js: src > lobbyclient > main.ts
  • game-server.bundle.js: src > gameserver > serverengine > main.ts
  • game-client.bundle.js: src > gameclient > clientengine > main.ts

Lobby / Game Server Relationship

The lobby is used to create rooms (i.e. game servers) and enable clients to connect to them as a player or a spectator. The lobby server is established by running the above command node lobby.js in the dist folder. If a client were to "create a room" then a child process of game-server.bundle.js would be spawned. The magic here happens in src > lobbyserver > spinupgameserver.ts


Debugging Child Node Process (using VS Code)

If you happen to be testing locally where you need both the lobby and game server instances running (and not running a game server instance by itself) you will need to set up a launch.json file for VS Code as follows:

{
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Child Node Process",
            "address": "localhost",
            "port": 9229,
        }
    ]
}

And in the spinupgameserver.ts file mentioned above you would need to make this adjustment when spawning the child process:

var child = cp.spawn("node --inspect-brk ./server/game-server.bundle.js " + port, { shell: true });

Next, you will need to spin up the lobby server as you normally would:

node lobby.js

Then, go to localhost:8080 and create a room.

Finally, when this child process is spawned, the process will rest at an internal breakpoint which will allow you to manually attach the debugger using your newly created launch.json in VS Code. Once attached you can continue debugging from the internal breakpoint to the first breakpoint that has been set in the child process' code.

boardhousenet's People

Contributors

jjwall avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

apples

boardhousenet's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.