• Stars
    star
    601
  • Rank 71,886 (Top 2 %)
  • Language
    JavaScript
  • Created about 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collaborative gameboy emulation powered 100% by JavaScript

weplay

How to install

Install with

$ npm install

Then run it with the following ENV vars:

  • WEPLAY_PORT - pointing to the port you want to listen on (3001)
  • WEPLAY_REDIS - redis uri (localhost:6379)
  • WEPLAY_SERVER_UID - unique persistent identifier for this server's instance. Used for keeping track of # of clients in redis (defaults to WEPLAY_PORT)
  • WEPLAY_IP_THROTTLE - the least amount of time in ms that need to pass between moves from the same IP address (100)
$ node index

This will set up the IO server for weplay. It's necessary that you also launch the other services:

  • weplay-web serves the HTML pages and static assets to run the game. It also serves initial state from Redis with the page for optimal performance.
  • weplay-emulator runs an emulator and broadcasts the image data from it with socket.io-emitter to the IO instance(s) that users are connected to.
  • weplay-presence notifies all the IO instance(s) of the aggregate number of online users.

FAQ

How does this all work?

The weplay-emulator service runs a JavaScript-based gameboy color emulator that gets painted to an instance of node-canvas.

Upon each draw an event is emitted and the PNG buffer is piped through Redis to all the IO instances of weplay (this project).

With Socket.IO 1.0 binary support, we can seamlessly transfer the image data contained in the Buffer to all the connected clients, in addition to all the JSON datastructures to make chat and commands work.

This makes weplay a 100% JavaScript project!

What are the error handling scenarios?

  • In the event of a crash of a weplay IO node, clients can be rerouted to another instance and reconnect automatically thanks to socket.io-client.
    • Events that are broadcasted to other users (such as chat messages and "x moved y" events) get persisted upon broadcast into a Redis capped list, which means that upon reconnection users will get the latest events despite having been routed to a new server.
    • The connection count will be eventually consistent and correct thanks to the work of the weplay-presence service that aggregates the connection counts of all servers.
  • In the event of a crash of weplay-emulator, the next time it boots up it restores the virtual machine state that gets persisted by default every 60 seconds (for performance reasons).

Support

If you have ideas or contributions, join #weplay on Freenode.

License

MIT

More Repositories

1

slackin

Public Slack organizations made easy
JavaScript
6,499
star
2

wifi-password

Get the password of the wifi you're on (bash)
Shell
4,352
star
3

blog

MDX
1,128
star
4

spot

Tiny file search utility (bash)
Shell
922
star
5

chat-example

HTML
798
star
6

next-ai-news

TypeScript
761
star
7

how-is-this-not-illegal

A demo of using RSC and Vercel Postgres, legally
JavaScript
572
star
8

clif

Dead easy terminal GIFs, from the terminal.
JavaScript
447
star
9

node.websocket.js

WebSocket-compatible realtime HTTP server implemented with Node.JS
JavaScript
265
star
10

react-postgres-components

An experiment on deploying remote functions that run inside Postgres using v8
TypeScript
158
star
11

node.dbslayer.js

DBSlayer (MySQL) support for Node.JS
JavaScript
150
star
12

jamstack-ecommerce

JavaScript
129
star
13

wordledge

TypeScript
120
star
14

chrome-spdy-indicator

Chrome Extension to see an indicator of SPDY support in the address bar.
JavaScript
108
star
15

smashingnode

Repository for my book "Smashing Node"
JavaScript
107
star
16

TextboxList

MooTools tokenizer
JavaScript
101
star
17

gameboy

JavaScript
89
star
18

chromekit

HTML5 window chroming
JavaScript
64
star
19

insights-chrome

IO Insights chrome extension
JavaScript
58
star
20

emoji-todo

A simple app to demonstate the ease of fetching and mutating data with Next.js App Router, RSC, and Server Actions.
TypeScript
53
star
21

raycast-web-dev-measure

Raycast extension to quickly measure a site's performance using PageSpeed Insights
Shell
52
star
22

blog-views

JavaScript
49
star
23

genui-demo

TypeScript
49
star
24

pokeless

JavaScript
47
star
25

latency-io

Socket.IO echo example with latency measurement / graphing
JavaScript
42
star
26

jsconf-todo-demo

Demo application using socket.io+nodestream for realtime, express+mongoose for backend
JavaScript
36
star
27

blog-starter

JavaScript
34
star
28

berkshire-deck-demo

JavaScript
30
star
29

PluginsKit

Plugins repository for open source projects linked to GitHub
PHP
25
star
30

weplay-emulator

runs the emulator that communicates with the weplay io backend
JavaScript
24
star
31

express-trace

Express route/middleware tracer & profiler
JavaScript
21
star
32

s.js

tiny javascript sprintf
JavaScript
20
star
33

gitfollow

Add a GitHub followers badge to your website!
JavaScript
18
star
34

jsconfar

CSS
18
star
35

Cube5

A CSS3 animated 3D Cube layout
15
star
36

phpshortener

PHP URL Shortening encoder/decoder class.
PHP
14
star
37

APNG

Animated PNG cross-browser utility.
JavaScript
13
star
38

moogets

Guillermo's MooTools plugins.
JavaScript
13
star
39

gox-now

Example of cross-compiling Go on Now and hosting the resulting binaries in the Now CDN
Dockerfile
13
star
40

weplay-web

JavaScript
12
star
41

mongoose-meetup-04-05

Examples used for the presentation
JavaScript
11
star
42

pkg-now

Example of cross-compiling Node.js on Now and hosting the resulting binaries in the Now CDN
Dockerfile
10
star
43

oscon-chat

My oscon presentation chat app
JavaScript
10
star
44

define.js

Tiny Node.js script to pull definitions from Google
JavaScript
9
star
45

project-template-next.js

Next.js template for CodeSandbox Projects
TypeScript
8
star
46

datocms-Gatsby-portfolio-demo

CSS
7
star
47

ios6-bugs

Test cases for iOS6 Mobile Safari bugs
JavaScript
7
star
48

weplay-presence

JavaScript
6
star
49

mdx-deck-theme-berkshire

JavaScript
3
star
50

thereallybigone

CSS
3
star
51

brevity

Brevity is an operating system. Itโ€™s easy to use, free, and based on Linuxโ€ and web technologies.
JavaScript
3
star
52

inception.js

2
star
53

router

Fork of reach/router to demonstrate Now CI
JavaScript
2
star
54

belkirk-jekyll-demo

HTML
1
star
55

sample-app

JavaScript
1
star
56

blob-to-image

JavaScript
1
star
57

hi-fregante

HTML
1
star