Logo Search packages:      
Sourcecode: jabber-jit version File versions  Download package

session it_session_create ( iti  ti,
jpacket  jp 
)

Create new session.

Parameters:
jp Packet with XDB REGISTER data leave semaphore up

Definition at line 18 of file session.c.

References session_st::client, session_st::from, session_st::id, session_st::last_time, session_st::orgid, session_st::p, session_st::q, session_st::queue, session_st::queue_last, session_st::reference_count, iti::sessions, iti::sessions_count, iti::sessions_sem, session_st::start_time, session_st::ti, session_st::type, iti::web_aware, and session_st::web_aware.

Referenced by it_unknown_presence().

{
    pool p;
    session s,t;

    log_debug(ZONE,"Creating session for %s",jid_full(jp->from));

    p = pool_heap(4096);
    s = pmalloco(p,sizeof(_session));
    s->p = p;
    s->ti = ti;
    s->q = mtq_new(p);

    s->id = jid_new(p,jid_full(jid_user(jp->from)));
    s->orgid = jid_new(p,jid_full(jp->from));
    jid_full(s->id);
    jid_full(s->orgid);
    s->from = jid_new(p,jid_full(jp->to));
    jid_set(s->from,"registered",JID_RESOURCE);
    jid_full(s->from);

    s->reference_count = 0;
    s->queue = NULL;
    s->queue_last = NULL;
    s->type = stype_normal;

    s->client = NULL;

    s->start_time = time(NULL);
    s->last_time = s->start_time;

    s->web_aware = ti->web_aware;
    
      SEM_LOCK(ti->sessions_sem);
    t = (session) wpxhash_get(ti->sessions,jid_full(s->id));
    if (t != NULL) {
      pool_free(p);
      return NULL;
    }
    wpxhash_put(ti->sessions,pstrdup(p,jid_full(s->id)),(void *) s);
    ti->sessions_count++;
    return s;
}


Generated by  Doxygen 1.6.0   Back to index