Is this possible? For example, having Rooms as Maps in an MMO game. Once a "door" is triggered, the room will move the player to the next specified room.
Hi @oyed,
Currently, the only way to achieve this is by manually sending a message from the server to the client you want to move, and, from the client-side, request to join into that room. See dummy example below:
Server-side:
// "previous_room" handler
this.send(client, { letsMoveTo: "next_room" });
Client-side
var previousRoom = client.join("previous_room");
previousRoom.onData.add(function(data) {
var nextRoom = client.join(data.letsMoveTo);
});
@endel Thanks - can I persist Client (Player) Data through rooms?
@oyed you're welcome! You'd need to persist the user data somewhere in between connections, such as a database or in memory.
I wouldn't recommend persisting in NodeJS's process, since when upgrading to the next version of the server (0.6.x) will break things. In the current version (0.5.x) it will be fine because it's a single process. Version 0.6.x will introduce multiple processes, and your rooms may live in a different process.
This is something I do as well (I have an RPG where each map is a room). Basically, I do it exactly as endel described - I tell the client to teleport, and the client initiates the request. I do some cleanup on the server, save the player, then when it leaves the room and joins the next one, the x, y, etc are already set. When the next version comes out, you'll be able to do promise validation in canJoin which will make it so you can check the database to verify that the map you're on is the map you should be on (for example).
Thanks for the help!
after 3 years. is there any update?
new method like jumpToRoom()?
or this solution still useable?
Hi @xfause, there are a couple of different ways of achieving this.
What I do on mazmorra is:
A more "secure" way of handling this, would be to use the matchMaker API in the server-side, and send the "seat reservation" data through a message for the client, and the client can the call .consumeSeatReservation().
You still need to connect and disconnect from the rooms manually, as the framework does not consider how your front-end is structured.