sessions.cc File Reference

handle messages to and from user sessions More...

#include "jsm.h"

Functions

void _js_session_start (void *arg)
void _js_session_to (void *arg)
void _js_session_from (void *arg)
void _js_session_end (void *arg)
void js_session_route (session s, xmlnode in)
void js_session_free_aux_data (void *arg)
session js_session_new (jsmi si, dpacket dp)
session js_sc_session_new (jsmi si, dpacket dp, xmlnode sc_session)
void js_session_end (session s, char *reason)
session js_session_get (udata user, char const *res)
session js_session_primary (udata user)
void js_session_to (session s, jpacket p)
void js_session_from (session s, jpacket p)

Detailed Description

handle messages to and from user sessions


Function Documentation

void _js_session_end ( void *  arg  ) 

child that cleans up a session

Notify the responsible c2s instance about the closed session. Call the modules that registered for the es_END event, to notify them about the closed session

Parameters:
arg the session, that is closing

References es_END, js_mapi_call(), js_session_route(), log_debug2, LOGT_SESSION, session_struct::p, pool_free(), session_struct::presence, udata_struct::ref, session_struct::sid, session_struct::u, xmlnode_free(), and ZONE.

Referenced by js_session_end().

void _js_session_from ( void *  arg  ) 
void _js_session_start ( void *  arg  ) 

child that starts a session

Calles all registered modules for the event e_SESSION and notifies them about the newly created session

Parameters:
arg the newly created session

References e_SESSION, js_mapi_call(), session_struct::si, session_struct::started, and session_struct::u.

Referenced by js_sc_session_new(), and js_session_new().

void _js_session_to ( void *  arg  ) 

child that handles packets to a specified resource (session) of a user

It is checked if the session the packet is addressed to has the exit_flag set, if so it is sent back (?) to js_deliver(). If the exit_flag is not set it is first tried if one of the registered callbacks for es_IN handles the packet. Iff not the exit_flag is checked again (and probably the packet sent back to js_deliver()) and if it is still not set, the packet is passed to js_session_route() which delivers it to the c2s for sending it to the connection related to the session.

Parameters:
arg the packet

References jpacket_struct::aux1, session_struct::c_in, es_FILTER_IN, es_IN, session_struct::exit_flag, jpacket_struct::flag, jpacket_struct::from, history_storage_conf::general, jsmi_struct::history_recv, udata_struct::id, jid_full(), JPACKET__ERROR, JPACKET__GROUPCHAT, JPACKET__HEADLINE, JPACKET_MESSAGE, jpacket_subtype(), js_deliver(), js_mapi_call(), js_session_route(), log_debug2, LOGT_DELIVER, NS_EVENT, NS_JABBERD_HISTORY, history_storage_conf::offline, PACKET_FROM_OFFLINE_MAGIC, PACKET_PASS_FILTERS_MAGIC, session_struct::si, history_storage_conf::special, jsmi_struct::std_namespace_prefixes, jpacket_struct::type, session_struct::u, jpacket_struct::x, jsmi_struct::xc, xdb_act(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_get_list_item(), xmlnode_get_tags(), xmlnode_hide_attrib_ns(), xmlnode_put_attrib_ns(), and ZONE.

Referenced by js_session_to().

session js_sc_session_new ( jsmi  si,
dpacket  dp,
xmlnode  sc_session 
)

create a new session, that was signaled by the c2s with the session control protocol

Sets up all the data associated with a new session, then notify all modules that registered for e_SESSION about the newly created session

Parameters:
si the session manager instance data
dp the packet we received from the c2s instance, that requested the new session
sc_session the xmlnode containing the sc:session element
Returns:
a pointer to the new session (NULL if input data is invalid)

References _js_session_start(), session_struct::aux_data, session_struct::c_in, session_struct::c_out, es_LAST, session_struct::events, session_struct::exit_flag, xmppd::jabberid::get_resource(), dpacket_struct::id, session_struct::id, j_strcmp(), jid_full(), jid_new(), JPACKET__UNAVAILABLE, js_session_end(), js_session_free_aux_data(), js_user(), jutil_presnew(), log_debug2, LOGT_SESSION, mtq_new(), mtq_send(), N_, session_struct::next, NS_SESSION, session_struct::p, pmalloco(), pool_cleanup(), pool_free(), pool_heap, session_struct::presence, session_struct::priority, pstrdup(), session_struct::q, session_struct::res, session_struct::roster, session_struct::route, session_struct::sc_c2s, jsmi_struct::sc_sessions, session_struct::sc_sm, udata_struct::sessions, session_struct::si, session_struct::sid, session_struct::u, dpacket_struct::x, xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_put_attrib_ns(), and ZONE.

Referenced by _js_routed_session_control_packet().

void js_session_end ( session  s,
char *  reason 
)

shut down the session

This function gets called when the user disconnects or when the server shuts down. It changes the user's presence to offline, cleans up the session data and notifies all registered modules for the es_END event about the closed session

Parameters:
s the session, that is closing
reason textual reason for the shutdown

References _js_session_end(), session_struct::exit_flag, session_struct::id, j_strcmp(), jid_full(), JPACKET__UNAVAILABLE, jutil_presnew(), log_debug2, LOGT_SESSION, messages_get(), mtq_send(), session_struct::next, session_struct::p, session_struct::presence, session_struct::priority, session_struct::q, udata_struct::ref, jsmi_struct::sc_sessions, session_struct::sc_sm, udata_struct::sessions, session_struct::si, session_struct::u, xhash_zap(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_get_lang(), xmlnode_put_attrib_ns(), and ZONE.

Referenced by __jsm_shutdown(), _js_routed_error_packet(), _js_routed_session_control_packet(), js_sc_session_new(), and js_session_new().

void js_session_free_aux_data ( void *  arg  ) 

delete the aux hash if a session structure is freed

References session_struct::aux_data, and xhash_free().

Referenced by js_sc_session_new(), and js_session_new().

void js_session_from ( session  s,
jpacket  p 
)

handle normal stanzas received inside a <route/> stanza from jabberd. These are packets we get from the client connection manager, that are from one of our users.

Pass them to _js_session_from() to get executed by an own execution thread.

Parameters:
s the session of the user
p the received packet

References _js_session_from(), jpacket_struct::aux1, log_debug, mtq_send(), jpacket_struct::p, session_struct::q, and ZONE.

Referenced by _js_routed_packet().

session js_session_get ( udata  user,
char const *  res 
)

find the session for a given resource

Given a user and a resource, find the corresponding session if the user is logged in. Otherweise return NULL.

Parameters:
user the user's udata record
res the resource to search for
Returns:
a pointer to the session if the user is logged in, NULL if the user isn't logged in on this resource

References j_strcmp(), j_strlen(), j_strncmp(), session_struct::next, session_struct::res, and udata_struct::sessions.

session js_session_new ( jsmi  si,
dpacket  dp 
)

create a new session, register the resource for it (initiated by the old c2s-sm-protocol)

Sets up all the data associated with a new session, then notify all modules that registered for e_SESSION about the newly created session

Parameters:
si the session manager instance data
dp the packet we received from the c2s instance, that requested the new session
Returns:
a pointer to the new session (NULL if input data is invalid)

References _js_session_start(), session_struct::aux_data, session_struct::c_in, session_struct::c_out, es_LAST, session_struct::events, session_struct::exit_flag, xmppd::jabberid::get_resource(), xmppd::jabberid::has_node(), xmppd::jabberid::has_resource(), session_struct::id, dpacket_struct::id, j_strcmp(), jid_full(), jid_new(), JID_RESOURCE, jid_set(), JPACKET__UNAVAILABLE, js_session_end(), js_session_free_aux_data(), js_user(), jutil_presnew(), log_debug2, LOGT_SESSION, mtq_new(), mtq_send(), N_, session_struct::next, session_struct::p, pmalloco(), pool_cleanup(), pool_heap, session_struct::presence, session_struct::priority, pstrdup(), session_struct::q, session_struct::res, session_struct::roster, session_struct::route, udata_struct::sessions, session_struct::si, session_struct::sid, session_struct::u, dpacket_struct::x, xhash_new(), xmlnode_get_attrib_ns(), xmlnode_put_attrib_ns(), and ZONE.

Referenced by _js_routed_session_packet().

session js_session_primary ( udata  user  ) 

find the primary session for the user

Scan through the user's sessions to find the session with the highest priority and return a pointer to it.

Parameters:
user the user to find the highest session for
Returns:
pointer to the primary session if the user is logged in with at least priority 0, NULL if there is no active session with a priority of at least 0

References session_struct::next, session_struct::priority, and udata_struct::sessions.

void js_session_route ( session  s,
xmlnode  in 
)

deliver a packet to the client connection manager responsible for the session

The packet is wrapped inside a <route/> element and routed to the client connection manager, that handles the connection for the sepcified session. If the xmlnode in is NULL, a <route type='error'/> stanza is sent to the client connection manager, signalling that the session is not valid anymore.

Parameters:
s the session to which the packet should be routed to
in the stanza that should be routed to the c2s for the session

References deliver(), dpacket_new(), jsmi_struct::i, jid_full(), messages_get(), N_, NS_SERVER, NS_SESSION, session_struct::presence, session_struct::route, session_struct::sc_c2s, session_struct::sc_sm, session_struct::si, session_struct::sid, xmlnode_get_lang(), xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), xmlnode_put_attrib_ns(), and xmlnode_wrap_ns().

Referenced by _js_session_end(), and _js_session_to().

void js_session_to ( session  s,
jpacket  p 
)

handle packets addresses to a specific resource (session) of a user

pass them to _js_session_to() ...

Parameters:
s the session the packet is addressed to
p the packet

References _js_session_to(), jpacket_struct::aux1, log_debug, mtq_send(), jpacket_struct::p, session_struct::q, and ZONE.

Referenced by _js_session_from().


Generated on Sat Mar 13 06:00:10 2010 for jabberd14 by  doxygen 1.6.1