How to join zone from server side

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Rakesh
Posts: 9
Joined: 23 Dec 2016, 13:33

How to join zone from server side

Postby Rakesh » 25 Aug 2017, 04:44

Hello ,
I want to join zone from server side and I find method getApi().login(ISession session, java.lang.String name, java.lang.String pass, java.lang.String zoneName, ISFSObject params) and login(ISession session, java.lang.String name, java.lang.String pass, java.lang.String zoneName, ISFSObject params, boolean forceLogout) . but what value I passed to session ? please give me example of server side code to join zone.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to join zone from server side

Postby Lapo » 25 Aug 2017, 07:02

Hi,
sorry I don't understand your question.

What does it mean to "join a zone from server side?"
You want to simulate a client in your Extension code? If so you can use the SFSApi.createNPC(...) method.

Here's a two part article talking about NPCs:
http://smartfoxserver.com/blog/ways-of- ... -game-p-1/
http://smartfoxserver.com/blog/ways-of- ... -game-p-2/

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
rgfernan
Posts: 11
Joined: 20 Mar 2010, 00:25
Location: Buenos Aires, Argentina
Contact:

Re: How to join zone from server side

Postby rgfernan » 25 Aug 2017, 19:29

I guess he means making a user automatically join a zone from server side. I guess that is not possible, since in login event you don't have an user yet.
I have a similar issue, but making a user automatically join a room. I used both room.addUser() and user.addJoinedRoom(), and in the server console I see them joined, but client side I don't receive the event, neither I can see the room using getLastJoinedRoom, so I can not send extension messages to that room.
Is there any way to achieve this?

Regards,
Roberto
Roberto G. Fernández
Technical Leader

WILLDOM, WE DO IT_
AR: +54 (11) 4821 1582
US: +1 (954) 905 7439
Skype: roberto.g.fernandez
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to join zone from server side

Postby Lapo » 26 Aug 2017, 09:36

Hi,
I guess he means making a user automatically join a zone from server side. I guess that is not possible, since in login event you don't have an user yet.

Exactly, this is not possible. SFS2X runs multiple Zones (or application, if you prefer) at once and it's the client that tells the server which Zone he/she wants to log into.

To join a user from server code just user SFSApi.joinRom(...)
Always look in the SFSApi class first. Chances are you'll find what you need there ;)
http://docs2x.smartfoxserver.com/Extens ... ension-api

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 51 guests