Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to determine Host presence without entering room

Avatar

Level 2
Is there a way to know if the host has arrived without
authenticating to a room?



I noticed that the room state is always hostHasNotArrived to
a non-authenticated guest and when a listener for ROOM_STATE_CHANGE
is attached to the sessions roomManager instance you do not receive
events until you enter the room as either a guest or an
authenticated user. Furthermore you receive two ROOM_STATE_CHANGE
events as soon as you enter the room, the first being a
hostHasNotArrived ( regardless of the actual host status ) and then
a second immediate ROOM_STATE_CHANGE event stating the correct
state of the room ( whatever it really is ).



The use case I am trying to solve for is in an application
designed to only be used by a guest user you would like to know the
presence of a host in a room. Otherwise you could enter a room as a
guest and wait forever. More importantly in the current
implementation if I attempt to log in as a guest and receive the
hostHasNotArrived status I would assume that there was no host when
in fact there is. Currently I have to ignore the hostHasNotArrived
and wait around for the second event.
16 Replies

Avatar

Former Community Member
Hi CS,



Thanks for the super-clear report. We'll look into the
double-event issue : If it's a bug (and it almost certainly is)
we'll get it for the next release drop.



As for the more general problem of knowing if there's a
host, if you want to do it client-only, we do force you to connect
to get this state. If you need to know the state before forcing
users to connect, most solutions involve you running a server to
either :



a. keep track of who you're sending to what apps, and the
roles you've given them via external auth. You'd keep a DB of who
went where.

2. Query an HTTP API from your server to ours, which would
return the list of users in a room. We haven't added support for
this, but are doing some speccing of how this API would look, which
we'll start sharing soonish.



let me know if that helps

nigel

Avatar

Level 2
Nigel,

thanks for the quick reply. I have a few questions regarding
the Host role in general. Hopefully the answers can help me devise
a workaround.



1.) Is the host and UserRoles.Owner synonymous

2.) Is a username and password authenticated user
automatically an Owner ( and based in answer #1 a host )?

3.) Can I rely on the hostCollection.length to determine if a
host is present?





The reason I am asking these questions is because when I
enter a room as a guest ( Only using username and no password ) I
am able to see the managers synch. Any subsequent log in attempts
by an authenticated ( username AND passowrd ) user result in the
user role being 5 which is LOBBY when they should be an OWNER?



Thanks in advance.

Avatar

Employee
I can answer #2: a host is a user with role=100



The "canonical" role for users with an AdobeID is that the
host is the account/room owner. So even if all users have an
AdobeID, only the owner will be the host.



If you are using external authentication, every user that get
assigned with role=100 will be a host.



Avatar

Former Community Member
Hi,

Answer to Question # 1: Yes , hosts have role value = 100
i.e. UserRoles.OWNER.

One additional note here is , if you enter using your
userName and password , there is also another parameter in
UserDescriptor called affiliation which is the role at root Level ,
that is also = 100 i.e. UserRoles.OWNER. However, if you come in as
guest , and then some host promotes you, you will still have role =
100 but an affiliation value equal to the role value you entered
with.

This affiliation parameter thus separates out host( entering
with UserName and Password) from users who are promoted to host
during the session.





Answer to Question #3: Once the user Manager is syncd, the
userCollection will have all users inside and hostCollection will
have the hosts , so you can use hostCollection.length I think for
getting number of hosts.



Thanks

Hironmay Basu



Avatar

Former Community Member


To add to the chorus,



re: seeing managers sych - I ran your code a few times, and
yeah, even in the case of Lobby, your ConnectSession does become
synchronized, so you can use that as the event to key off of, and
inspect RoomManager.roomState - if it's hostHasNotArrived, then you
know what's up, otherwise there's a host. Users in the lobby don't
have rights to see the userManager's collections, so that would
turn up a bust. I think we should be more consistent around naming
- as I'm guessing you're the only one who's using this state, would
it burn you if we changed this state to ownerHasNotArrived for the
next build? We've tried to stay consistent and use the more general
"owner" rather than "host", but this one slipped through with some
Breeze-era terminology.



Re: your last question - we've isolated this issue -
apparently if you log in first as guest, then change your code to
login as owner, your browser might be holding onto the previous
session and log you in as guest again. Clearing or closing the
browser will reset this, but we think we might be able to fix it
too; we're working on it.



hope all that helps

nigel

Avatar

Level 2
Thanks guys!

I think it would be a very good idea to remove all references
to host since it has been a source of quite a few confusing
conversations in our office.



I appreciate Hironmay's explanation of what differentiates
the username and password Owner owner from a promoted user ( that
was going to be my next question btw ).



The session caching has been giving me hell since day one, I
am about to start debugging on separate vm's so I can get around
it. We'll see if that helps. If you do find a caching fix for us
poor developers you would earn my undying gratitude.



Thanks again for the quick feedback. I am truly enjoying AFCS
and will keep cranking out demos as fast as I can.



Will let you know when I get the workaround in there and will
post a completed code sample with it working.

Avatar

Level 2
So then how does one determine whether a Host has arrived?



The hostCollection seems to always remain at a length of 0
for me.



The RoomState changes to active even when a host is not there
in all the tests I have run.



Is there a way to determine that there is a host?

Avatar

Former Community Member
Hi,

RoomState should not change to ACTIVE if the host is not
there. We will look into it.



Thanks

Hironmay Basu

Avatar

Former Community Member
Hi ConnectSolutions,

As you correctly pointed out, there is some bug in our code
that keeps the room active and you dont receive any events or
notification if you are entering as guest and waiting and the host
arrives. Also, since you havent entered yet i.e your role is still
5 i.e. UserRoles.LOBBY , you can't access any of the UserManager's
collections and will get a length of 0 always. We will be fixing
this with priority .



But you can get around the problem as of now, by having a
small shared model of yours ( any collectionNode or sharedModel
will do) where you create a node and publish a message on it from
the Owner's side whenever the owner/host enters to notify everyone
that he has entered. Just remember to set the accessmodel of
NodeConfiguration of node on which you are publishing to LOBBY ie.
role = 5 , and make the publishModel = 100 so that only owners can
publish on this node. In this way , any users waiting will be
receiving this message and will know the host has arrived. If you
can't get this sharedModel concept to work, let me know. I will try
to run on my side.



And as of our side regarding actual fix, we will fix this use
case and put in the next drop of SDK and also update in forum about
it.



On the host side though, he is always notified when he enters
if there are pending users knocking to enter. See the KnockingQueue
example in case you want to explore that.



Thanks

Hironmay Basu

Avatar

Level 2
Hironmay ,

Thanks for the info.

In the long run the custom shared model is probably the best
approach.



Your continued support is greatly appreciated.

Avatar

Former Community Member
Hi,



Yes we from our side we will fix so that guests get some
notfication when hosts come and go, however, if you keep your
shared model , it gives you a flexibility to notify and send any
other messages as you require.



Thanks

Hironmay Basu

Avatar

Level 3

Has this been fixed? I am still getting a

userManager.hostCollection.length  == 0

when a host is present.  I'm using the latest drop, 0.93, I think. I looked in the release notes, but they lack details.  Please advise.    I'm trying to avoid the workaround.  If I need the work around , how do I get access to a sample project?  Thanks!

Avatar

Former Community Member

Sorry, it seems this one fell through the cracks - can you describe the use case you're aiming for here? We'll try to figure out what we can do.

nigel

Avatar

Level 3

I have a guest in the lobby, waiting for the knocking queue to be answered. I want let them know that the host is not present (and that they may have a long wait, or what hours they might expect the host to arrive), so the last thing I do is to check the hostCollection length.   I hope this makes sense and is enough info.

Would you mind commenting on my unrelated post about an empty collection node going away?

Thanks a ton for the quick reply.

--Doug

Avatar

Level 3

Hi Folks,

I attempted a fix following Hironay's recipe and knocking enabled for a guest user.  I created a collectionNode and place a node "OwnerIsPresent" with accessModel=UserRoles.LOBBY.  I login as host, and keep the browser open. I open a second guest session and looking at the collection node, but the "OwnerIsPresent" is missing.    Since knocking is enabled, my guest is UserRoles.LOBBY (I think). If my guest is UserRoles.VIEWER (10), then this work, but I'll lose the knocking functionality. 

Please help, I really need this to work.  I have a test case based upon the LoginDialog.mxml example, if that will help.

Avatar

Former Community Member

Hi ,

Do you mean you can't see a node with accessModel=UserRoles.LOBBY when your userrole is equal to the LOBBY. Can you send me the prototype code you are using ?

Thanks

Hironmay Basu