xerdi:presence

v0.0.2Published last year

Meteor Presence

A simple wrapper for the user-status package.

Installation

Add the package to your project:

meteor add xerdi:presence

Usage

The service is automatically started on login and stopped on logout.

Client Side Functions

It can be started/stopped manually and there is a way to get the status of the service:

1import {Presence} from 'meteor/xerdi:presence';
2import log from 'meteor/xerdi:logging';
3
4log.info(`Presence status ${Presence.status()}`);
5
6Presence.start();
7// OR
8Presence.stop();

Schema Definition

In order for the service to work the user needs an additional schema.

1import {Meteor} from "meteor/meteor";
2import SimpleSchema from "simpl-schema";
3
4const UsersStatusSchema = new SimpleSchema({
5    lastLogin: {
6        type: Object,
7        optional: true,
8    },
9    'lastLogin.date': {
10        type: Date,
11        optional: true,
12    },
13    'lastLogin.ipAddr': {
14        type: String,
15        optional: true,
16    },
17    'lastLogin.userAgent': {
18        type: String,
19        optional: true,
20    },
21    'idle': {
22        type: Boolean,
23        optional: true,
24    },
25    'lastActivity': {
26        type: Date,
27        optional: true,
28    },
29    'online': {
30        type: Boolean,
31        optional: true,
32    },
33});
34Meteor.users.schema = new SimpleSchema({
35    // ... other fields
36    status: {
37        type: UsersStatusSchema,
38        optional: true
39    }
40});
41Meteor.users.attachSchema(Meteor.users.schema);