Software /
code /
prosody
Diff
core/sessionmanager.lua @ 304:7b28fa8bbfe5
Code cleanup for resource binding
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 16 Nov 2008 03:16:53 +0500 |
parent | 176:e5cd2a03891d |
child | 309:d9c8825b7332 |
line wrap: on
line diff
--- a/core/sessionmanager.lua Sun Nov 16 02:52:54 2008 +0500 +++ b/core/sessionmanager.lua Sun Nov 16 03:16:53 2008 +0500 @@ -68,9 +68,13 @@ return true; end +-- returns true, nil on success +-- returns nil, err_type, err, err_message on failure function bind_resource(session, resource) - if not session.username then return false, "auth"; end - if session.resource then return false, "constraint"; end -- We don't support binding multiple resources + if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end + 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 + resource = resource or uuid_generate(); --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing @@ -79,7 +83,7 @@ else if hosts[session.host].sessions[session.username].sessions[resource] then -- Resource conflict - return false, "conflict"; -- TODO kick old resource + return nil, "cancel", "conflict", "Resource already exists"; -- TODO kick old resource end end