Ezelia / eureca.io

eureca.io : a nodejs bidirectional RPC that can use WebSocket, WebRTC or XHR fallback as transport layers
http://eureca.io/
343 stars 30 forks source link

example for launching mutliple servers #6

Closed fyyyyy closed 9 years ago

fyyyyy commented 9 years ago

its it possible to run several eureca instances on the same node instance ? could you provide an example how to launch servers via a route, e.g. GET /games/myroom => launches new eureca server

Cheers

alaa-eddine commented 9 years ago

each eureca.io instance have to be attached to an httpserver or express server. so all you have to do to make multiple eureca.io servers is to attach them to new express/http servers and listen to different port.

but seeing your request example I don't think that this is what you need. if what you want is creating multiple "rooms" for a game, this should be handeled in the same server, no need for multiple servers here, it'll make the job more complex.

to handle rooms all you have to do is a function in the server side that create a room (represented by an array or a hashtable ...etc) then return a unique identifier for this room. another function will allow a player to join a room given an identifier.

fyyyyy commented 9 years ago

Thanks, haven't thought of that. This is much easier than expected. By the way i find this is an excellent network library for working with phaser/pixi :+1:

alaa-eddine commented 9 years ago

The main goal of eureca.io is to make client/server developement as "natural" as possible :) not only for gaming stuff.

glad you find it useful .