+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 36

Thread: converting from early es4 to es5

  1. #11
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    Yes, in most cases the only change from the ES4 server code is the import lines (and adding new features). See also ElectroServerApi and PluginApi in the Server API javadocs. For example, a plugin can use getApi().addUsersToRoom or getApi().getUsersInRoom, and a room-level plugin can get the users in its own room with getApi().getUsers(). Either way, after you have a list of the users, you just use .size() to get the count of users.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  2. #12
    Member
    Join Date
    Jul 2010
    Posts
    39
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks, the pointers helped.
    What is the call to get all rooms the user is in (previous call was getJoinedRooms())?

  3. #13
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    There isn't a single call for this that I can find. You would need to use _es.managerHelper.zoneManager.zones to get the array of zones, then iterate through all rooms in each zone. For each Room object, check the isJoined property. There may be an easier way to do this. In ES4 there was a getJoinedRooms() method in the Zone class but I'm not seeing that for ES5.

    edit: I added a Feature Request to put this functionality into ES5.
    Last edited by tcarr; 10-15-2010 at 08:44 PM.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  4. #14
    Member
    Join Date
    Jul 2010
    Posts
    39
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks you.

    Question about Persistent rooms, once we add them through admin, are the saved internally?. When do i have to reenter hem again. I am not sure about how it works currently?. Through xml was so much easier?

  5. #15
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    If you add a Persistent Room through the admin, it is stored in the database. If you publish it, it's live immediately. If you don't publish it, it will be published when ElectroServer restarts. It is also possible to add persistent rooms using a plugin.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  6. #16
    Member
    Join Date
    Jul 2010
    Posts
    39
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi Teresa,
    Still on the question on user getJoinedRooms, i couldn't find the api you mentioned. Could you eleborate on how to get all the rooms, the user is in?. where is isJoined()?
    This is from a plugin?

    similarly for room.leaveRoom do i use kickUser?
    Last edited by bota999; 10-18-2010 at 06:22 PM.

  7. #17
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    Ah, I thought you wanted it from the client side. There isn't any such feature on the server side. Do you need it?

    From the client side, to leave a room you send a LeaveRoomRequest. From the server side, you can use getApi().kickUserFromRoom.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  8. #18
    Member
    Join Date
    Jul 2010
    Posts
    39
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes please,
    I need to find a user and report where among various servers, where is he located in which room/zone?

  9. #19
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    If this is going to be done infrequently, then you would need to use lines such as these:
    Code:
    // find all the zones, so you can get the zoneIds
    Collection<ZoneValue> zones = getApi().getZones();
    
    // iterate through all the zoneIds
    Collection<RoomValue> rooms = getApi().getRoomsInZone(zoneId);
    
    // iterate through all the roomIds in each zone
    Collection<UserValue> usersInRoom = getApi().getUsersInRoom(zoneId, roomId);
    
    // if the user you care about is in the usersInRoom collection, add this room (zoneId + roomId combo) to a list or just process this room for this user
    This is NOT efficient by any means if you have multiple zones and lots of rooms. If this is going to be done fairly often, then what you will want to do is maintain a data structure either on a server level plugin or in a managed object. When a client joins a room that has a plugin attached, the plugin can record this. For rooms that have no plugin, the client would need to send a plugin request to a server level plugin with the details. I would suggest either have a plugin on every room, or else always have the client send a plugin request to do the update, instead of mixing the two.

    If you need this information shared between different servers, then you may want the info stored into a database (possibly updating a batch every couple of seconds instead of individual updates).
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  10. #20
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    Further thought: if you aren't sure whether this user is on a given server at all, this line would check for that:
    Code:
    boolean isLoggedInToThisServer = getApi().isUserLoggedIn(userName);
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts