kanetempleton.com / JBend / live demo
This page was served by JBend
JBend is a Java backend I wrote from the socket up: its own HTTP server, WebSocket server, database layer, accounts and config language, with no framework underneath. This is one JBend process running right now. Below is what it is doing.
Read from api/status every five seconds, printed the way the launcher logs its own startup.
Two games run inside it
JBGame
A multiplayer tile world. Walk an island, see other players move, chat. The server ticks five times a second and streams the map in 50×50 sections. Play as a guest, or register and your position is saved.
Play JBGameThe Floor Is Lava
Tiles bubble, go quiet, then turn to lava; the last player standing wins. It runs on my first multiplayer server, from 2018, with its own packet format. The Java server runs as a thread here; the browser client speaks its original protocol through a WebSocket bridge and shows every packet as it goes by.
Play The Floor Is LavaHow a request gets here
browser | https / wss Cloudflare | Go web server (kanetempleton.com) proxies /JBend/demo/ to 127.0.0.1:8090 | JBend HTTP server :8090 --------------- pages, game clients, docs, /api |-- /ws/jbgame -> WebSocket server :8091 -> JBGame engine (5 ticks/s) |-- /ws/game2018 -> WebSocket bridge :8092 -> 2018 server, TCP :10018 '-- database thread -> MySQL (the same database the Go site uses)
The whole application is one file
JBend's Main has two lines in it. What gets started is decided by config/application.conf.
This is the one running this demo, comments trimmed:
app-id:jbend-demo dataserver: source env:DB_DSN # the Go site's database, from the same variable prefix jbend_ login: sessions 7d webserver: listen 8090 bind 127.0.0.1 home pages mount /jbgame build/jbgame # JBGame's client, from its own repository mount /game2018 build/game2018 mount /docs build/docs upgrade /ws/jbgame 8091 # hand these WebSocket paths to the servers below upgrade /ws/game2018 8092 websocket: listen 8091 bind 127.0.0.1 handler com.game.net.GameSocket app: class com.game.Engine # JBGame's game loop app: class server.Embedded # the 2018 server, as a thread bridge: listen 8092 bind 127.0.0.1 target 127.0.0.1 10018 # WebSocket in, plain TCP out caretaker: interval 30m
More
- Documentation: guides, the config reference and the API.
- JBend on GitHub.
- My other games, including a multiplayer C game that also runs in the browser.