prologin.presencesync.server module

PresenceSync server: sends logged users changes to PresenceSync clients, accept or deny connection requests from presencd daemons instances and mainain a list of logged users, taking care of timeouts thanks to heartbeats.

class prologin.presencesync.server.GetListHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

get()
class prologin.presencesync.server.HeartbeatHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

post()
class prologin.presencesync.server.LoginHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

post()
class prologin.presencesync.server.LogoutHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

post()
class prologin.presencesync.server.RemoveExpiredHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

post()
class prologin.presencesync.server.SyncServer(pub_secret, sub_secret, port)

Bases: prologin.synchronisation.Server

create_pubsub_queue()

Initially, no user is logged. Heartbeats are trusted, so we can rebuild the state with them.

get_handlers()

Return a list of URL/request handlers couples for this server.

loop_removing_expired()

Loop forever, asking the PrecenceSync server to remove expired logins periodically.

start()

Run the server.

class prologin.presencesync.server.TimeoutedPubSubQueue

Bases: prologin.synchronisation.BasePubSubQueue

Maintain a backlog of logged in users per machine. Take care of information expiration.

The internal backlog is a little bit exotic here: it’s a mapping: user login -> (expiration timestamp, hostname). Filtering out expired information has to be triggered externally: this class just provide a function to do it.

get_backlog_message()

Return an update message-formatted backlog. Check for expired logins first.

get_list()

Return a mapping: login -> hostname for all logged in users. Check for expired logins first.

is_login_allowed(login, hostname)

Return None if login is allowed to log on hostname, or a reason message if not.

item_to_update(update_type, login, hostname)
notify_logout(login, hostname)
remove_and_publish_expired()

Remove expired users and publish updates for it if needed.

remove_and_publish_users(logins)
remove_expired()

Remove expired users and return the set of removed logins.

request_login(login, hostname)

Try to register login as logged on hostname. Return None if successful, and if it is, send an update for it. Return a failure reason otherwise. Also check for expired logins first.

start()
update_backlog(login, hostname)

Register login as logged on hostname. Send needed update messages. Check for expired logins first. Should be used only internally.

update_with_heartbeat(login, hostname)

Accept and register as-is the association between login and hostname, sending an update message if needed. Check for expired logins first.