Software /
code /
prosody
Diff
core/sessionmanager.lua @ 569:5216efe6088b
Add hostmanager, and eventmanager
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 06 Dec 2008 03:41:49 +0000 |
parent | 565:3a49d85cafbc |
child | 583:5821eaa80baa |
line wrap: on
line diff
--- a/core/sessionmanager.lua Sat Dec 06 03:40:51 2008 +0000 +++ b/core/sessionmanager.lua Sat Dec 06 03:41:49 2008 +0000 @@ -35,6 +35,10 @@ local rm_load_roster = require "core.rostermanager".load_roster; local config_get = require "core.configmanager".get; +local fire_event = require "core.eventmanager".fire_event; + +local gettime = require "socket".gettime; + local st = require "util.stanza"; local newproxy = newproxy; @@ -45,7 +49,7 @@ local open_sessions = 0; function new_session(conn) - local session = { conn = conn, priority = 0, type = "c2s_unauthed" }; + local session = { conn = conn, priority = 0, type = "c2s_unauthed", conntime = gettime() }; if true then session.trace = newproxy(true); getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("Session got collected, now "..open_sessions.." sessions are allocated") end; @@ -109,6 +113,8 @@ if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end -- We don't support binding multiple resources + session.conntimetotal = gettime()-session.conntime; + resource = resource or uuid_generate(); --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing @@ -175,7 +181,7 @@ local features = st.stanza("stream:features"); - modulemanager.fire_event("stream-features", session, features); + fire_event("stream-features", session, features); send(features);