Implement a Master - Slave relationship?

568 views
Skip to first unread message

Paul Canning

unread,
Oct 30, 2013, 1:05:43 PM10/30/13
to nod...@googlegroups.com
I'm looking to make some small games that can be played over a local network (or if the app is published online, private rooms using socket.io)

Is there a way to set one device, say an iPad, as the "Master" device (image the dealer in Poker) and then have the connected clients (people on their own tablet or smartphone) as the "Slaves".

It would mean the Master has a different display to the Slaves (for the Poker example, the Master would show the community cards and the Slaves would only see their 2 cards).

I'm certain this is possible, but I'd like some pointers on how to differentiate the master from the slaves and show different information to either party.

Aria Stewart

unread,
Nov 1, 2013, 8:04:03 PM11/1/13
to nod...@googlegroups.com
In this context, I'd suggest that you've got two problems: First, the clients
all have to connect -- if there's no server, that means a shared network of
some sort. If there is, that may well be where the logic should live (unless
you're going to invent a protocol for them to talk to each other and agree on
state. This way possibly leads to madness, since distributed systems are hard.)

The next stage would be having each client read that shared state and display
appropriately. If there's a central server, it can arbitrate all that and only
show clients what they need to see; if there's not, well, now you have 2N+1
problems, and replication is just one.

The player who's in charge of a game does not neccesarily have to be the same
machine that runs that game. Servers are nice that way.

Aria

Paul Canning

unread,
Nov 4, 2013, 5:12:08 AM11/4/13
to nod...@googlegroups.com
In this instance, the "Master" will be essentially "Player 1" and gets assigned, in the Poker example, as the dealer (display for the community cards).

My post is asking more of a "how to" rather then the idea.

Are there any examples of what I am describing? Are there any packages that help implement this kind of multi-user relationship? I will be using Socket.io (or similar) to deal with the data flow over websockets, and I know this has rooms, which will be utilised.

Is there a way to find users automatically on the same LAN?

Ryan Schmidt

unread,
Nov 4, 2013, 4:42:01 PM11/4/13
to nod...@googlegroups.com

On Nov 4, 2013, at 04:12, Paul Canning wrote:

> Is there a way to find users automatically on the same LAN?

http://en.wikipedia.org/wiki/Zero-configuration_networking

Alejandro de Brito Fontes

unread,
Nov 6, 2013, 10:35:36 AM11/6/13
to nod...@googlegroups.com
Hi, If you want to do something using the LAN this can help https://github.com/wankdanker/node-discover (look the examples/master.js file)
The first user will be the master and any other user a "slave". If the master disconnect it will elect a new master.

Or you can use something like https://github.com/stianeikeland/node-etcd to create the same thing but without using the broadcast address (using http with less network overhead)
Reply all
Reply to author
Forward
0 new messages