Hi
I need to get all users and rooms by using javascript without any event listener just to call function for users and rooms with intervals for updations
Thanks
How to get all users and rooms from sfs using javascript
-
- Posts: 3
- Joined: 30 Dec 2016, 09:57
Re: How to get all users and rooms from sfs using javascript
Hi,
you can create this from server side and then call the Extension from a Javascript client.
I need to warn you that it may not be a good idea to send a global list of users and rooms if the server is very trafficked as you may have thousands of Rooms and clients, which in turn would generate very large data.
Cheers
you can create this from server side and then call the Extension from a Javascript client.
I need to warn you that it may not be a good idea to send a global list of users and rooms if the server is very trafficked as you may have thousands of Rooms and clients, which in turn would generate very large data.
Cheers
-
- Posts: 3
- Joined: 30 Dec 2016, 09:57
Re: How to get all users and rooms from sfs using javascript
can you please tell me how should i implement the same?
which class and method i need to use to get whole data
Please give me one example
Thanks
which class and method i need to use to get whole data
Please give me one example
Thanks
Re: How to get all users and rooms from sfs using javascript
If you're familiar with developing Extensions you can access the Zone's current room list and User list like this:
You can serialize the User or Room object by calling toSFSArray() and deserialize them via the User or Room newFromSFSArray() method on the client side.
cheers
Code: Select all
Collection<User> userList = getParentZone().getUserList();
List<Room> roomList = getParentZone().getRoomList();
You can serialize the User or Room object by calling toSFSArray() and deserialize them via the User or Room newFromSFSArray() method on the client side.
cheers
Re: How to get all users and rooms from sfs using javascript
Actually since you're using Javascript the method to deserialize is called "fromArray".
Sorry for the confusion.
Sorry for the confusion.
-
- Posts: 33
- Joined: 28 Sep 2018, 19:47
Re: How to get all users and rooms from sfs using javascript
Lapo wrote:I need to warn you that it may not be a good idea to send a global list of users and rooms if the server is very trafficked as you may have thousands of Rooms and clients, which in turn would generate very large data.
I also plan to include a global user list of around 200 active users.
What about the server sends a single update on every join and left event? I would just submit the username and if he/she left or logged in. I am not sure because this would cause multiple events per second on high traffic - but they would be small. Is there a limit of events per seconds I should try not to exceed? Better a lot of small updates or every two seconds one big update for such cases?
Re: How to get all users and rooms from sfs using javascript
FireSmartFox wrote:Lapo wrote:I need to warn you that it may not be a good idea to send a global list of users and rooms if the server is very trafficked as you may have thousands of Rooms and clients, which in turn would generate very large data.
I also plan to include a global user list of around 200 active users.
What about the server sends a single update on every join and left event?
The server already does that at Room Level. In other words when you join a Room you get the full list of users present in that Room and you get updated every time a new user enters or leaves.
To see this in action check the basic Examples we provide for your favorite platform:
https://www.smartfoxserver.com/download ... p=examples
You can also follow the relative tutorials here:
http://docs2x.smartfoxserver.com/
(Just click the Examples sections in the left side menu)
Cheers
Return to “SFS2X HTML5 / JavaScript API”
Who is online
Users browsing this forum: No registered users and 19 guests