User list with Orbiter

All Union Platform questions, comments, feature requests, and bug reports.

User list with Orbiter

Postby wkolcz » Fri 01 Aug 2014 22:05

I am attempting to create a user list of 'whos online' for an application I have developed. When I attempt to add a new user, all the values of the list become the most current user and not a collection of them. I tried it on different browsers to make sure the sessions weren't getting interfered with and can see each person who logs in still have their own identity in the application. Can you see what I am doing wrong? I am using Laravel 4.2 with Blade templating so it might explain why the {{Session::get('first_name')}} might look a little odd.

Code: Select all
function init () {
            orbiter = new net.user1.orbiter.Orbiter();
            orbiter.getConnectionMonitor().setAutoReconnectFrequency(15000);
            orbiter.getLog().setLevel(net.user1.logger.Logger.DEBUG);

            orbiter.addEventListener(net.user1.orbiter.OrbiterEvent.READY, readyListener, this);
            orbiter.addEventListener(net.user1.orbiter.OrbiterEvent.CLOSE, closeListener, this);

            occupantlist = document.getElementById("occupantlist");
            occupantlist.style.width = "100%";

            orbiter.connect("tryunion.com", 80);
        }

        //==============================================================================
        // ORBITER EVENT LISTENERS
        //==============================================================================
        function readyListener (e) {
            chatRoom = orbiter.getRoomManager().createRoom("{{Str::slug(Session::get('rescue_name')).'-'.Session::get('org_id')}}");
            chatRoom.addEventListener(net.user1.orbiter.RoomEvent.ADD_OCCUPANT, addOccupantListener);
            chatRoom.addEventListener(net.user1.orbiter.RoomEvent.REMOVE_OCCUPANT, removeOccupantListener);
            chatRoom.join();
        }

        // Triggered when the connection is closed
        function closeListener (e) {

        }

        function addOccupantListener (e) {
            addListOption("{{Session::get('first_name')}} {{Session::get('last_name')}}", e.getClientID());
        }

        function removeOccupantListener (e) {
            alert('Elvis has left the building');
            removeListOption(e.getClientID());
        }

        function addListOption (name, value) {
            var ul = document.getElementById("occupantlist");
            var li = document.createElement("li");
            li.setAttribute("id", value);
            li.appendChild(document.createTextNode(name));
            ul.appendChild(li);
        }

        function removeListOption (value) {
            var elem = document.getElementById(value);
            elem.parentNode.removeChild(elem);
        }


Thanks and let me know if you can tell me how to create a list of each person logged in.
wkolcz
 
Posts: 7
Joined: Fri 13 Apr 2012 06:55

Re: User list with Orbiter

Postby toby » Mon 04 Aug 2014 03:15

Have you tried this?

Code: Select all
// get a ClientManager instance, and then call getClients()
cliManager = orbiter.getClientManager();
clientList = cliManager.getClients();


See http://unionplatform.com/docs/reactor/a ... etClients()
(or the analogous page for your version)

The detailed documentation is provided for Reactor rather than Orbiter.
toby
 
Posts: 162
Joined: Sun 24 Jun 2012 14:18


Return to Union Platform

Online

Users browsing this forum: No registered users and 10 guests