Code Monkey home page Code Monkey logo

meteor-user-status's Introduction

user-status

What's this do?

Keeps track of user connection data, such as IP addresses, user agents, and client-side activity, and tracks this information in Meteor.users as well as some other objects. This allows you to easily see users that are online, for applications such as rendering the users box below showing online users in green and idle users in orange.

User online states

For a complete example of what can be tracked, including inactivity, IP addresses, and user agents, check out a demo app at http://user-status.meteor.com, or its source.

Install

Install using Meteor:

$ meteor add mizzao:user-status

Additionally, note that to read client IP addresses properly, you must set the HTTP_FORWARDED_COUNT environment variable for your app, and make sure that IP address headers are forwarded for any reverse proxy installed in front of the app. See the Meteor docs on this for more details.

Basic Usage - Online State

This package maintains two types of status: a general user online flag in Meteor.users, and some additional data for each session. It uses timesync to maintain the server's time across all clients, regardless of whether they have the correct time.

Meteor.users receives a status field will be updated automatically if the user logs in or logs out, closes their browser, or otherwise disconnects. A user is online if at least one connection with that userId is logged in. It contains the following fields:

  • online: true if there is at least one connection online for this user
  • lastLogin: information about the most recent login of the user, with the fields date, ipAddr, and userAgent.
  • idle: true if all connections for this user are idle. Requires idle tracking to be turned on for all connections, as below.
  • lastActivity: if the user was idle, the last time an action was observed. This field is only available when the user is online and idle. It does not maintain the user's last activity in real time or a stored value indefinitely - lastLogin is a coarse approximation to that. For more information, see #80.

To make this available on the client, use a reactive cursor, such as by creating a publication on the server:

Meteor.publish("userStatus", function() {
  return Meteor.users.find({ "status.online": true }, { fields: { ... } });
});

or you can use this to do certain actions when users go online and offline.

Meteor.users.find({ "status.online": true }).observe({
  added: function(id) {
    // id just came online
  },
  removed: function(id) {
    // id just went offline
  }
});

You can use a reactive cursor to select online users in a client-side template helper:

Template.foo.usersOnline = function() {
  return Meteor.users.find({ "status.online": true })
};

Making this directly available on the client allows for useful template renderings of user state. For example, with something like the following you get the picture above (using bootstrap classes).

<template name="userPill">
    <span class="label {{labelClass}}">{{username}}</span>
</template>
Template.userPill.labelClass = function() {
  if (this.status.idle)
    return "label-warning"
  else if (this.status.online)
    return "label-success"
  else
    return "label-default"
};

Advanced Usage and Idle Tracking

Client API

On the client, the UserStatus object provides for seamless automatic monitoring of a client's idle state. By default, it will listen for all clicks and keypresses in window as signals of a user's action. It has the following functions:

  • startMonitor: a function taking an object with fields threshold (the amount of time before a user is counted as idle), interval (how often to check if a client has gone idle), and idleOnBlur (whether to count a window blur as a user going idle.) This function enables idle tracking on the client.
  • stopMonitor: stops the running monitor.
  • pingMonitor: if the automatic event handlers aren't catching what you need, you can manually ping the monitor to signal that a user is doing something and reset the idle monitor.
  • isIdle: a reactive variable signifying whether the user is currently idle or not.
  • isMonitoring: a reactive variable for whether the monitor is running.
  • lastActivity: a reactive variable for the last action recorded by the user (according to server time). Since this variable will be invalidated a lot and cause many recomputations, it's best only used for debugging or diagnostics (as in the demo).

For an example of how the above functions are used, see the demo.

Server API

The UserStatus.connections (in-memory) collection contains information for all connections on the server, in the following fields:

  • _id: the connection id.
  • userId: the user id, if the connection is authenticated.
  • ipAddr: the remote address of the connection. A user logged in from different places will have one document per connection.
  • userAgent: the user agent of the connection.
  • loginTime: if authenticated, when the user logged in with this connection.
  • idle: true if idle monitoring is enabled on this connection and the client has gone idle.

startupQuerySelector (Optional)

On startup meteor-user-status automatically resets all users to offline and then marks each online as connections are reestablished.

To customize this functionality you can use the startupQuerySelector Meteor package option like this:

  "packages": {
    "mizzao:user-status": {
      "startupQuerySelector": { "$or": [{ "status.online": true }, { "status.idle": { "$exists": true } }, { "status.lastActivity": { "$exists": true } }] }
    }
  }

The above example reduces server/database load during startup if you have a large number of users.

Usage with collection2

If your project is using aldeed:collection2 with a schema attached to Meteor.users, you need to add the following items to the schema to allow modifications of the status:

import SimpleSchema from 'simpl-schema';

const userSchema = new SimpleSchema({
    status: {
        type: Object,
        optional: true,
    },
    'status.lastLogin': {
        type: Object,
        optional: true,
    },
    'status.lastLogin.date': {
        type: Date,
        optional: true,
    },
    'status.lastLogin.ipAddr': {
        type: String,
        optional: true,
    },
    'status.lastLogin.userAgent': {
        type: String,
        optional: true,
    },
    'status.idle': {
        type: Boolean,
        optional: true,
    },
    'status.lastActivity': {
        type: Date,
        optional: true,
    },
    'status.online': {
        type: Boolean,
        optional: true,
    },
});

// attaching the Schema to Meteor.users will extend it
Meteor.users.attachSchema(userSchema);

Events

The UserStatus.events object is an EventEmitter on which you can listen for connections logging in and out. Logging out includes closing the browser; reopening the browser will trigger a new login event. The following events are supported:

UserStatus.events.on("connectionLogin", function(fields) { ... })

fields contains userId, connectionId, ipAddr, userAgent, and loginTime.

UserStatus.events.on("connectionLogout", function(fields) { ... })

fields contains userId, connectionId, lastActivity, and logoutTime.

UserStatus.events.on("connectionIdle", function(fields) { ... })

fields contains userId, connectionId, and lastActivity.

UserStatus.events.on("connectionActive", function(fields) { ... })

fields contains userId, connectionId, and lastActivity.

Check out https://github.com/mizzao/meteor-accounts-testing for a simple accounts drop-in that you can use to test your app - this is also used in the demo.

Startup selector

By default, the startup selector for resetting user status is {}. If you want to change that you can set the default selector in your settings.json file:

{
  "packages": {
    "mizzao:user-status": {
      "startupQuerySelector": {
        // your selector here, for example:
        "profile.name": "admin"
      }
    }
  }
}

Testing

There are some Tinytest unit tests that are used to test the logic in this package, but general testing with many users and connections is hard. Hence, we have set up a demo app (http://user-status.meteor.com) for testing that is also hosted as a proof of concept. If you think you've found a bug in the package, try to replicate it on the demo app and post an issue with steps to reproduce.

Contributing

See Contributing.md.

meteor-user-status's People

Contributors

antobinary avatar arunoda avatar dependabot[bot] avatar fidelsam1992 avatar foysalit avatar hlehmann avatar jankapunkt avatar jeremysaks avatar kastork avatar kristerv avatar merlinstardust avatar mizzao avatar rafaelsales avatar ridersshare avatar rijk avatar storytellercz avatar vparpoil avatar wreiske avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meteor-user-status's Issues

Browser closing hook

I would like to know if there is any hooks available to detect a browser closing and to be able to run a function (log the user out) on that hook.

Potential disconnect event needed for anonymous users

The connectionIdle event triggers instead.

Is this a browser issue?

Edit: Oh, if I'm logged in, and I close the window tab, then the connectionLogout event triggers, but if I'm not logged in and I close the browser, connectionIdle triggers.

Should there be a connectionClose event, given that idling is arguably qualitatively different than closing?

Replace socket.on("close") with Meteor.onConnection

Meteor's connection onClose is better than using the SockJS close event because it catches the DDP heartbeat timeout as well.

Switch the null publish function over to this, and make sure the Meteor source code does what it's supposed to be doing with both SockJS and the DDP heartbeat timeout.

See 8ef35ba.

How do I start monitoring as soon as the client is synced?

In my application I want to start monitoring the user as he logs in. For that I looked at your demo app and wrote an analogous code:

Deps.autorun(function(c) {
        UserStatus.startMonitor({
            threshold: 1000,
            interval: 1000,
            idleOnBlur: false
}

But i'm always having the "Can't start idle monitor until synced to server" error. I suppose Deps.autorun isn't good sync identification. Don't really understand how it works in the demo actually, how the computation object marks that the server and client re in sync?

Possible solution may be to use timesync package, but I prefer to avoid from adding unnecessary packages .

cannot add package to project

meteor add mizzao:user-status returns: 'mizzao:user-status: no such package'
trying to install with meteorite smart package from this git repository returns:
=> Errors while scanning packages:

While building package user-status:
package.js:8:9: Object # has no method 'onUse'

/usr/local/lib/node_modules/meteorite/lib/command.js:41
throw "Command exited with " + code + "/" + signal;
^
Command exited with 1/null

How to get IP address of current visitor in Helper

I tried using this approach but I get undefined as the value for the variable named clientIpAddress.

Meteor.methods({
    getClientIpAddress: function () {
        return this.connection.clientAddress;
    }
});

Template.home.helpers({
    starsAlreadyReceivedFromIpAddress: function () {
        var clientIpAddress;
        Meteor.call("getClientIpAddress", function(err, ipAddress) {
            clientIpAddress = ipAddress;
        });
        console.log(clientIpAddress);
        ....
    }
});

So I wanted to ask that if using this package I could get the current visitors IP address in the helper method.

ipAddr sometimes wrong

ipAddr is correct for about 90% of users. About 10% have it as 127.0.0.1. I have HTTP_FORWARDED_COUNT set to 1. Any idea why it would sometimes be correct and sometimes not?

Add client hooks for user status change

Can we get some event calls on the client like on the server? I am already doing this locally with my Emitter package but it would be nice to have something built in.

Namely:

  • connectionLogin
  • connectionLogout
  • connectionIdle
  • connectionActive

Multiplexing bug: user can be left in an online state even when no sessions are connected

As observed occasionally on http://user-status.meteor.com, e.g. the following (the zizizi user is online but has no sessions.)

image

Currently unknown how this can be reproduced. If anyone can figure it out, we should fix it!

Hints:

TypeError: Object #<Object> has no method 'on'

When i launch mrt, i have the following error :

W20140318-16:09:09.937(0)? (STDERR) /root/.meteor/tools/f3947a4651/lib/node_modules/fibers/future.js:173
W20140318-16:09:09.939(0)? (STDERR)                         throw(ex);
W20140318-16:09:09.944(0)? (STDERR)                               ^
W20140318-16:09:09.947(0)? (STDERR) TypeError: Object #<Object> has no method 'on'
W20140318-16:09:09.948(0)? (STDERR)     at app/server/Accounts.js:25:12
W20140318-16:09:09.950(0)? (STDERR)     at app/server/Accounts.js:35:3
W20140318-16:09:09.951(0)? (STDERR)     at /D/poc-users/.meteor/local/build/programs/server/boot.js:155:10
W20140318-16:09:09.952(0)? (STDERR)     at Array.forEach (native)
W20140318-16:09:09.953(0)? (STDERR)     at Function._.each._.forEach (/root/.meteor/tools/f3947a4651/lib/node_modules/underscore/underscore.js:79:11)
W20140318-16:09:09.954(0)? (STDERR)     at /D/poc-users/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8

Here is the code snippet in Accounts.js

Meteor.publish("userStatus", function() {
  return Meteor.users.find({
    "status.online": true
  });
});
....
UserStatus.on("sessionLogin", function(advice) {
  winston.log('info', 'User login', { metadata : JSON.stringify(advice)});
  return ;
});

mrt --version
Meteorite version 0.7.2
Release 0.7.1.2
smart.json

{
  "packages": {
    "collectionFS": {},
    "bootstrap-3": {},
    "winston": {},
    "winston-mongodb": {
      "path": "./packages/meteor-winston-mongodb"
    },
    "ogno-admin": {},
    "iron-router": {},
    "collection2": {},
    "datatables": {},
    "winston-client": {},
    "user-status": {},
    "roles": {}
  }
}

.meteor/packages

standard-app-packages
preserve-inputs
accounts-base
accounts-ui
accounts-password
roles
user-status
iron-router
collectionFS
cfsfilehandlerserver
cfs-public-folder
winston
winston-mongodb
winston-client
collection2
ogno-admin
datatables
bootstrap-3

Was working fine until i add the roles package ...
mrt test-packages user-status works fine - all green.

Meteor.logout() in IE8/9 does not change online status immediately

There is an observed delay of 30-60 seconds between calling Meteor.logout() on IE8 & IE9 browsers and the data record having status.online == "false".

See the Mongo query and two records below. The second record has no loginTokens immediately after a Meteor.logout() call in IE8 & IE9, but the online status is still "true". In 30-60 seconds, this record will have its online status change to "false", but I am unsure what event triggers this delayed change.

This bug does not affect Firefox or Chrome, where a call to Meteor.logout() immediately sets the online status to "false" as expected.

meteor:PRIMARY> db.users.find({'status.online': true}, {'services.resume.loginTokens': 1, 'status.online': 1})

{ "_id" : "KDtaASeBcRu95d54c", "services" : { "resume" : { "loginTokens" : [    {   "token" : "DAygECQnQ2SsGupcF",  "when" : ISODate("2014-01-02T21:27:51.960Z") } ] } }, "status" : { "online" : true } }
{ "_id" : "2rpis2ryT3g2iXbes", "services" : { "resume" : { "loginTokens" : [ ] } }, "status" : { "online" : true } }

Logging out and back in in the same browser with multiple windows open breaks tracking

If two windows of the same browser are open (different sessions) and a user logs out and back in as someone else, the tracking breaks because the other session will get authenticated as the new user as well but retains the same socket that the previous user was using. Numbers will be fudged until the second session ends, counting toward the old user.

This isn't a huge deal right now because it really only comes up when testing apps, but I'm recording it here for reference.

Why do my users not have a status.online flag?

I just created a fresh project using mrt

and the status.online flag is no where to be found on any of the logged in users.

is this package outdated or is there something I'm not understanding?

User-status doesn't work with shark branch

Today i tried the latest shark branch and meteor doesn't start, it complains about a problem with missing coffeescript (which i doesn't use).
The problem happens arround installation of the mkdirp npm package (probably related to missing rights).

npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz
npm ERR! addPlacedTarball Could not remove "/home/wistily/.npm/mkdirp/0.3.5/package"
npm ERR! Error: EACCES, unlink '/home/vjau/.npm/mkdirp/0.3.5/package'
npm ERR! { [Error: EACCES, unlink '/home/vjau/.npm/mkdirp/0.3.5/package']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/vjau/.npm/mkdirp/0.3.5/package',
npm ERR! parent: 'coffee-script' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator

Problem doesn't happen on 0.7.1.2
Problem doesn't happen when i remove user-status.

Get IP of current user?

Can I use this package to get the IP or connection id of the user who is currently doing some action on the server, such as inserting a document in a collection?

This would be in order to have some superficial tracking of not logged in users. Thanks.

Multiple server support

As Meteor begins to deploy in a distributed fashion, this package will need to work across multiple servers. At a minimum, we'll need to do the following:

  • move UserConnections into the database from an in-memory collection
  • Have servers track their connections so as not to step on each other
  • Remove connections from servers that have gone down (i.e. what we do in Meteor.startup right now after a HCR)

A more extensive discussion of this is in dburles/meteor-presence#7.

Error in the readme

Found a js error in your syntax... the filter parameter of the find() should be wrapped, it's not coffee รœ
return Meteor.users.find({ "status.online": true }, {fields: { username: true }});

User-configurable online state

I see that profile.online still exists despite the new status property on the user. I'm guessing this is to keep backwards compatibility?

It would be cool if users could set a custom online state (like in Gmail) in their profile, but one that switches to "offline" or "false" when they're not active.

If anyone else sees this as useful, I'll try to work on a PR this week to add a simple way to manage this.

User never goes idle in cordova

Hi,

Im using this package with meteor (v1.0.1) Cordova on iOS. It works 100% on browser and on mobile browser - but when in Cordova the user never goes idle. Any ideas?

Thanks.

Regards,
Riaan

Feature Request: 'audit-argument-checks' package compatibility

At current, calling userStatus.startMonitor() from client results in errors where Meteor's package audit-argument-checks has been added.

Exception while invoking method 'user-status-active' Error: Did not check() all arguments during call to 'user-status-active'
Exception while invoking method 'user-status-idle' Error: Did not check() all arguments during call to 'user-status-idle'

A quick addition of check(arguments, [Match.Any]) or something more robust could address this.

The status.online field will be removed automatically when user was offline for a period of time

Hi, I found something interesting when using this package.

It works well when monitoring the user's status. But I found that when the user was offline for a period of time, the status.online will be remove automatically.

# when the user is online
meteor:PRIMARY> db.users.findOne({username: 'xxx'})
...
"status" : {
        "lastLogin" : {
            "date" : ISODate("2014-08-06T01:58:35.217Z"),
            "ipAddr" : "127.0.0.1",
            "userAgent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36 OPR/23.0.1522.60"
        },
        "online" : true
},
...

# once the user is offline
meteor:PRIMARY> db.users.findOne({username: 'xxx'})
...
"status" : {
        "lastLogin" : {
            "date" : ISODate("2014-08-06T01:58:35.217Z"),
            "ipAddr" : "127.0.0.1",
            "userAgent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36 OPR/23.0.1522.60"
        },
        "online" : false
},
...

# the user is offline for a period of time
meteor:PRIMARY> db.users.findOne({username: 'xxx'})
...
"status" : {
        "lastLogin" : {
            "date" : ISODate("2014-08-06T01:58:35.217Z"),
            "ipAddr" : "127.0.0.1",
            "userAgent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36 OPR/23.0.1522.60"
        }
       # online field will be remove
},
...

Is there any way to keep the status.online field ?

Online field removed after some time

I'm having an issue in my app, after some time the online field in the user is removed, even if user is still online.

Maybe during that time connection was lost and recovered at some point, if I reload the page online status is back.

Thanks :)

Fetching userId

Meteor.publish("userStatus", function() {
  return Meteor.users.find({ "status.online": true }, 
    { 
        fields: { status:1, userId: Posts.find(id).userId } 
    });
});

I'm trying to publish only the OP's status by grabbing the userId field from the posts attributes.

My intentions are so that it loads faster.

Apparently, I apparently am doing something wrong.

Help please!

Track all connections, not just those from logged in users.

In future versions of this package it would be good to track all connections to the server, not just those from users that are logged in. This would involve the following changes to the code:

  • Use Meteor.onConnection to detect when sessions connect to the server, and attach the socket close handler there. (Currently, the publish handler does this for us and notifies of user login changes.)
  • Use login and logout hooks to appropriately update the state of connections that log in or out and attach them to a user.

How can I access my _id client-side?

Very nice package. I'm trying to use it but I've met some problems, because I'm just so noob.

If I'm an anonymous user, how can I get my _id?

I can access the _id collections, but how do I pick mine?

Connection ID for user [question]

Hi,

I need to know what connection belong to what user on the client. Any suggestions how I can do that?

I want to limit the amount of projects a user can create without logging into the system per connection.

Regards,
Riaan

ipAddr does not honor x-forwarded-for

Connection collection has ipAddr element for each connection which shows false values if there is a reverse proxy in front of Meteor (a very common deployment practice).

I would expect x-forwarded-for header to be recognized if it exists.

Same user logging from different browsers doesn't respect the logged in status in the other browser

Update: just saw the comment in the code:
`# TODO: fix possible inconsistency if user has multiple windows open

Thanks for working on this. Is great for one user logging in and out and works well for showing their status.

It would be great to be able to have the status stay set to online while any browsers are connected to the server for the same user.

Use case for me is that I have a teacher logging in multiple times for each of their student, but needing to use their login. Would be good to see at least when all have disconnected. Ideally would be able to keep track of status for each connection (might be beyond the scope of this project).

Find out which 'room' the user is in?

hello, thanks for this package.

is there a recommended way for me to use this package to find out which 'room' my user is located in at the moment? Or perhaps, how many users are at "/room/12cbi32132"?

Missing data...

I copied per the example.. monitoring is on and the time sync is working but there is no data...

all it says is "(last login ) (active or not monitoring)" - no times, durations, ips, etc.

Exception while invoking method 'login' Error: A login method must specify a userId or an error

When i run the test-packages on user-status with
Meteorite version 0.7.2
Release 0.7.2
i have the following error :

I20140320-13:56:42.160(0)? Exception while invoking method 'login' Error: A login method must specify a userId or an error
I20140320-13:56:42.291(0)?     at attemptLogin (packages/accounts-base/accounts_server.js:231)
I20140320-13:56:42.292(0)?     at Meteor.methods.login (packages/accounts-base/accounts_server.js:405)
I20140320-13:56:42.292(0)?     at maybeAuditArgumentChecks (packages/livedata/livedata_server.js:1405)
I20140320-13:56:42.292(0)?     at packages/livedata/livedata_server.js:580
I20140320-13:56:42.293(0)?     at _.extend.withValue (packages/meteor/dynamics_nodejs.js:37)
I20140320-13:56:42.293(0)?     at packages/livedata/livedata_server.js:579
I20140320-13:56:42.294(0)?     at _.extend.withValue (packages/meteor/dynamics_nodejs.js:37)
I20140320-13:56:42.294(0)?     at _.extend.protocol_handlers.method (packages/livedata/livedata_server.js:578)
I20140320-13:56:42.295(0)?     at packages/livedata/livedata_server.js:483
I20140320-13:56:44.972(0)? Exception while invoking method 'login' Error: A login method must specify a userId or an error
I20140320-13:56:44.972(0)?     at attemptLogin (packages/accounts-base/accounts_server.js:231)
I20140320-13:56:44.973(0)?     at Meteor.methods.login (packages/accounts-base/accounts_server.js:405)
I20140320-13:56:44.974(0)?     at maybeAuditArgumentChecks (packages/livedata/livedata_server.js:1405)
I20140320-13:56:44.974(0)?     at packages/livedata/livedata_server.js:580
I20140320-13:56:44.975(0)?     at _.extend.withValue (packages/meteor/dynamics_nodejs.js:37)
I20140320-13:56:44.975(0)?     at packages/livedata/livedata_server.js:579
I20140320-13:56:44.976(0)?     at _.extend.withValue (packages/meteor/dynamics_nodejs.js:37)
I20140320-13:56:44.977(0)?     at _.extend.protocol_handlers.method (packages/livedata/livedata_server.js:578)
I20140320-13:56:44.978(0)?     at packages/livedata/livedata_server.js:483

19 tests on 26 passed


status
waiting...     C: login
waiting...     C: online recorded on server
waiting...     C: session recorded on server
waiting...     C: online recorded on client
waiting...     C: logout
waiting...     C: offline recorded on server
waiting...     C: session deleted on server
PASS 21 ms S: adding one session
PASS 23 ms S: adding and removing one session
PASS 19 ms S: logout and then close one session
PASS 51 ms S: idling one session
PASS 31 ms S: idling and reactivating one session
PASS 28 ms S: idling and removing one session
PASS 57 ms S: idling and reconnecting one session

Best way to create some test Users that are always "online"?

Since I'm developing on my own, I would like to create several test user accounts (created initially in fixtures) that are always "online." What's the best way to do this? Even if I set status.online: true in the fixtures (via Accounts.onCreateUser()) I bet it would just get changed to false as soon as the package runs.

Question: how will this affect the performance of my app?

Hi,

Just wondering what sort of load this adds to my app? If every client is now updating the server whether it's online or not, will it hurt my app's performance? I ask because it's a package I could do without, but it would be nice to make use of it.

UserStatus is not defined in test environment

I'm having strange issue with UserStatus in test environment. Running meteor test-packages fails with ReferenceError saying that UserStatus is not defined although package is properly included.
Moreover such error appears: The package mizzao:user-status at 0.2.0 is incompatible with Meteor 0.9.0 or later. I've checked meteor directory and version 0.2.0 of user-status package indeed exists there. It gets installed while running meteor test-packages command. Explicitly pointing to use version 0.6.3 of user-status in on_test section of package.js solves the problem but that should not be necessary.
Here is the replication of the issue: https://github.com/abditus113/user-status-bug. Simply clone and run meteor test-packages
Any idea why that might be happening?

Meteor.logout() and resetting loginTokens give 60 second delay on offline-status in Chrome

Hi,

This has been working fine earlier, and I am not sure exactly when this started. When I remotely log out(remove loginTokens), or manually log out a user that is logged in with Chrome Version 32.0.1700.77, there is an exact timespan of 60 seconds before the user.status is set to offline. This looks similar to #10.

It works fine in FF26.

Is this a feature, or is it something holding the connection for 60 seconds before setting the user offline?

Do you need more info?

propose change in date format from number to native ISODate

Hi,

I'm using the package now. I realize dates are stored in number format:

"status" : {
        "lastLogin" : 1396215352000
    },

Wouldn't it be better to save dates in their native date form new Date() ?

That way mongo save it in the following format

ISODate("2014-03-15T18:03:35.208Z")

Then we can also do quick queries like

{'status.lastLogin': {$gte: new Date() }}

Redirect from server site event

I am using this server site event and from here I want user to redirect to some specific URL.

UserStatus.events.on("connectionLogin", function(fields) { ... })

Users can remain online even when their sessions get disconnected

Currently not sure how to replicate. Could be a multiplexing bug with reloads mixed in.

Observed in TurkServer after several hundred user connections (the 1 session below is the admin):

image

UAs of these "stuck" users seem to be pretty recent browsers, including latest Chrome:

"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36", 
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0", 
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:30.0) Gecko/20100101 Firefox/30.0", 
"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0", 
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36", 
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0", 
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0"

These will get cleared when the server restarts, but are generally troublesome for determining when someone has actually gone away.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.