+ Reply to Thread
Results 1 to 8 of 8

Thread: Dynamically-Generated Rooms & Extensions

  1. #1
    Senior Member
    Join Date
    Jul 2008
    Posts
    341
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Post Dynamically-Generated Rooms & Extensions

    I'm noticing a bit of interesting behavior when creating a persistent room from within an extension. If I manually create the room and attach a room-level plugin to it in ES5Admin, the plugin attaches as requested and all is good in the universe. I can see that the room exists via the server monitor and has the proper plugin attached. However, when creating the room dynamically, said room no longer has a persistent state and is destroyed as soon as it is created. Unless there's some voodoo that I'm missing to attach a room plugin properly to a persistent room, this seems highly unusual & bug-like.

    Here's the code that I'm using to create my room.
    Code:
    RoomConfiguration roomVal = new RoomConfiguration();
    roomVal.setName("room"+roomGen.toString());
    roomVal.setCapacity(-1);
    roomVal.setHidden(false);
    
    ExtensionComponentConfiguration roomPlugin = new ExtensionComponentConfiguration();
    roomPlugin.setHandle("TestRoom");
    roomPlugin.setName("TestRoom");
    roomPlugin.setExtensionName("TestRoom");
    
    roomVal.addPlugin(roomPlugin);
    
    roomVal.setPersistent(true);
    
    Collection<UserConfig> roomUsers = new ArrayList<UserConfig>();
    
    getApi().createRoomInNamedZone(currRoom.getString("RoomName"), true, roomVal, roomUsers);
    Last edited by tcarr; 11-03-2010 at 06:33 PM. Reason: problem solved, so changed the prefix

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,279
    Thanks
    81
    Thanked 1,092 Times in 1,081 Posts
    I'll try to reproduce this. I know I tested PersistentRoomCreate before ES5.0.0 was released, but I haven't tested that particular example lately.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,279
    Thanks
    81
    Thanked 1,092 Times in 1,081 Posts
    I added a plugin to the PersistentRoomCreate example, made PersistentRoomCreate a server level plugin, then restarted my ES5. The persistent room with plugin attached shows in the Zones and Rooms screen. Restarting ES5 shows that the room is created again each time.

    I don't see anything wrong with your code, although there are a few differences between it and what I have. You may want to try commenting out the plugin attachment part to see if that is the problem. Are you creating the persistent room from a server level plugin or a room level one? I haven't tried doing it from a room level plugin. Do you get any errors showing in the ES5 log?

    Here's the type of code that I'm using (omitting the imports and the package line):
    Code:
    public class PersistentRoomCreate extends BasePlugin {
    
        @Override
        public void init(EsObjectRO parameters) {
            // create the room configuration
            RoomConfiguration config = new RoomConfiguration();
            config.setName("example-room");
            config.setDescription("Description of example room");
            config.setCapacity(100);
            config.setHidden(false);
            config.setPersistent(true);
    
            // used to add users to the room
            Collection<UserConfig> userConfigs = new ArrayList<UserConfig>();
    
            // Optional: add any plugins to the room
            // You will have to supply the extensionName and pluginName for the plugin
            ExtensionComponentConfiguration roomPlugin = new ExtensionComponentConfiguration();
            roomPlugin.setExtensionName(getApi().getExtensionName());
            roomPlugin.setHandle("AvatarChatPlugin");
            roomPlugin.setName("AvatarChatPlugin");
    
            //add the room plugin(s)
            config.addPlugin(roomPlugin);
            
            
            // create the room
            RoomResponse response = getApi().createRoomInNamedZone("example-zone", true, config, userConfigs);
            
            if (response.getStatus() == Status.Success) {
                getApi().getLogger().debug("Persistent Room creation successful." +
                            "\n\tZone ID: " + response.getZoneId() +
                            "\n\tRoom ID: " + response.getRoomId());
            } else {
                getApi().getLogger().debug(response.getStatus().toString());
                for (ErrorType errorType : response.getErrors()) {
                    getApi().getLogger().debug(errorType.toString());
                }
            }
        }
    
    }
    And the Extension.xml file is:
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <Extension>
    	<Name>PersistentRoomCreate</Name>
        <Plugins>
            <Plugin>
                <Handle>PersistentRoomCreateExample</Handle>
                <Type>Java</Type>
                <Path>com.electrotank.electroserver5.examples.persistentroomcreate.PersistentRoomCreate</Path>
            </Plugin>
            <Plugin>
                <Handle>AvatarChatPlugin</Handle>
                <Type>Java</Type>
                <Path>com.electrotank.electroserver5.examples.avatarchat.AvatarChatPlugin</Path>
            </Plugin>
        </Plugins>
    </Extension>
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  4. #4
    Senior Member
    Join Date
    Jul 2008
    Posts
    341
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I'm creating it from within a server plugin with no errors. If I omit the plugin part, the rooms are created and persist correctly. It's only when I decide to add a plugin to them that they don't exist after creation.

  5. #5
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,279
    Thanks
    81
    Thanked 1,092 Times in 1,081 Posts
    It sounds as if there's a problem with either your code to add the plugin, or with the plugin instantiating. Can a client create a dynamic room with that plugin attached? If so, then the plugin instantiates correctly and you need to look at your lines that add it to the persistent room.

    Is your plugin in the same extension as the server level plugin? If so, use roomPlugin.setExtensionName(getApi().getExtensionN ame()); to set the extension name correctly. I haven't tested using two different extensions (one for the server level plugin, one for the room level plugin for the persistent room).
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  6. #6
    Senior Member
    Join Date
    Jul 2008
    Posts
    341
    Thanks
    0
    Thanked 2 Times in 2 Posts
    The extension name did the trick. Interesting. Everything works now. Figures it'd be coder oversight rather than a bug. I think I've been spending way too many hours on this project already.

    Thanks again, T. You're awesome.

  7. #7
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,279
    Thanks
    81
    Thanked 1,092 Times in 1,081 Posts
    It's the typos that are the hardest bugs to spot. I remember back in the late 1970's spending most of a week fighting a bug in a Fortran program that turned out to be using I = J instead of J = I. My mad debug skillz have greatly improved since then of course.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  8. #8
    Senior Member
    Join Date
    Jul 2008
    Posts
    341
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Yeah, no joke. Just be glad it's not something like forgetting chars when doing things as simple as declaring functions. Guilty.

+ 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