MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Highlighting users who are logged in. (Zatvorena) (Mono Support )

17013 put(a) pogledan, 8 odgovor(a) 3.10.2012. 14:14:58Kreirao(la) johnsamuel
johnsamuel

johnsamuel

3.10.2012. 14:14:58
Hi,
We want to show on the home page which show the avatar of Users when they are logged in. Additionally we want to show on the group pages members of those groups who are logged in. Finally on the friends section of the profile page we want to show which of the friends are logged in.

Is there away to identify people logged in and highlight them?

(We don't want formal tracking as in the Blog raised by Super 4 weeks ago)
Ovaj sadržaj još nije ocijenjen. 
429 Reputacija 46 Ukupno objava
denis

denis

4.10.2012. 15:05:02
Tracking the login status of other users is a difficult task - you could use the LastLoginDate field from the aspnet_Membership table, but there are no guarantees that a user is still active on the site using any time window. MonoX does not have a built-in functionality that would support something like this.
Ovaj sadržaj još nije ocijenjen. 
7207 Reputacija 956 Ukupno objava
khorvat

khorvat

5.10.2012. 7:57:35
I just want to add one more thing that you can use, although this is also not accurate as Denis mentioned, there is IsOnline property on the ASP.NET MembershipUser object but note that this relies on the LastActivityDate which isn't updated that much as per:

The LastActivityDate for a user is updated to the current date and time by the CreateUser and ValidateUser methods, and can be updated by some overloads of the GetUser method. You can use the UpdateUser method to set the LastActivityDate property to a specific date and time.
 
The LastActivityDate is used to determine whether a user is online. A user is considered online if the current date and time minus the UserIsOnlineTimeWindow property value is earlier than the LastActivityDate for the user.
In some scenarios we are using a small service method which will update that value and call to that service method is scheduled on client-side so that LastActivityDate can be more accurate.

/// <summary>
/// Updates users online status.
/// </summary>
/// <param name="userIds">User ids.</param>
[WebMethod]
public void UpdateUserOnlineStatus(string[] userIds)
{
    var userId = SecurityUtility.GetUserId();
    Task.Factory.StartNew(() => GenericRepository.GetInstance().UpdateLastActivityDate(userId, DateTime.Now));
}
private void UpdateLastActivityDate(Guid userId, DateTime date)
 {
     try
     {
         AspnetUsersEntity user = new AspnetUsersEntity();
         user.LastActivityDate = date.ToUniversalTime();
         RelationPredicateBucket bucket = new RelationPredicateBucket();
         bucket.PredicateExpression.Add(AspnetUsersFields.UserId == userId);
         UpdateEntitiesDirectly(user, bucket);
     }
     catch { }
 }
var users = new Array();
users.push('SomeUserId');
GenericService.UpdateUserOnlineStatus(users, function (result) {
});
Regards
Ovaj sadržaj još nije ocijenjen. 
15993 Reputacija 2214 Ukupno objava
johnsamuel

johnsamuel

19.10.2012. 8:58:31
Thanks for your answers. From this am I correct in understanding that currently there is no way of monitoring logged in /logged out status? Please advise.

If this is not available I'll add this to the development request list as it is an important feature to encourage interactivity within a community.
Ovaj sadržaj još nije ocijenjen. 
429 Reputacija 46 Ukupno objava
khorvat

khorvat

19.10.2012. 9:25:44
Yes you can track if user is online or not, but not as accurate as in solution I have provided you with.

there is IsOnline property on the ASP.NET MembershipUser object but note that this relies on the LastActivityDate which isn't updated that much as per:

The LastActivityDate for a user is updated to the current date and time by the CreateUser and ValidateUser methods, and can be updated by some overloads of the GetUser method. You can use the UpdateUser method to set the LastActivityDate property to a specific date and time. The LastActivityDate is used to determine whether a user is online. A user is considered online if the current date and time minus the UserIsOnlineTimeWindow property value is earlier than the LastActivityDate for the user.
I'm not sure that MonoX should have that kind of tracking (client-side one), but if you feel like it should please go ahead and add feature request.

Regards
Ovaj sadržaj još nije ocijenjen. 
15993 Reputacija 2214 Ukupno objava
johnsamuel

johnsamuel

19.10.2012. 10:18:12
Thanks Khorvat, will logging in update the LastActivityDate for a User?
Ovaj sadržaj još nije ocijenjen. 
429 Reputacija 46 Ukupno objava
khorvat

khorvat

19.10.2012. 10:30:42
Yes, it will update the LastActivityDate. This is ASP.NET Membership built-in behavior.
Ovaj sadržaj još nije ocijenjen. 
15993 Reputacija 2214 Ukupno objava
johnsamuel

johnsamuel

19.10.2012. 10:34:43
Thanks Khorvat, pl close this topic.
Ovaj sadržaj još nije ocijenjen. 
429 Reputacija 46 Ukupno objava