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. (Closed) (Mono Support )

Viewed 9803 time(s), 8 post(s) 10/3/2012 2:14:58 PMby johnsamuel
johnsamuel

johnsamuel

10/3/2012 2:14:58 PM
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)
This content has not been rated yet. 
429 Reputation 46 Total posts
denis

denis

10/4/2012 3:05:02 PM
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.
This content has not been rated yet. 
7207 Reputation 956 Total posts
khorvat

khorvat

10/5/2012 7:57:35 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts
johnsamuel

johnsamuel

10/19/2012 8:58:31 AM
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.
This content has not been rated yet. 
429 Reputation 46 Total posts
khorvat

khorvat

10/19/2012 9:25:44 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts
johnsamuel

johnsamuel

10/19/2012 10:18:12 AM
Thanks Khorvat, will logging in update the LastActivityDate for a User?
This content has not been rated yet. 
429 Reputation 46 Total posts
khorvat

khorvat

10/19/2012 10:30:42 AM
Yes, it will update the LastActivityDate. This is ASP.NET Membership built-in behavior.
This content has not been rated yet. 
15993 Reputation 2214 Total posts
johnsamuel

johnsamuel

10/19/2012 10:34:43 AM
Thanks Khorvat, pl close this topic.
This content has not been rated yet. 
429 Reputation 46 Total posts