Package javax.sip.header

Examples of javax.sip.header.EventHeader


            Request req = dialog.createRequest(Request.NOTIFY);

            // later - handle challenges, add accumulated authorization hdrs
            // here

            EventHeader ehdr = parent.getHeaderFactory().createEventHeader(
                    eventType);
            if (eventId != null)
            {
                ehdr.setEventId(eventId);
            }
            req.addHeader(ehdr);

            String state = getSubscriptionState();
            SubscriptionStateHeader hdr = parent.getHeaderFactory()
View Full Code Here


    public static String determineEventId(Request request) // assumes event
    // header
    // already validated
    {
        EventHeader ev = (EventHeader) request.getHeader(EventHeader.NAME);

        String event_id = ev.getEventId();
        if (event_id == null)
        {
            event_id = "";
        }
View Full Code Here

            {
                debug("SipPresence: Received SUBSCRIBE: " + request);
            }

            // look at the event header first
            EventHeader ev_hdr = (EventHeader) request
                    .getHeader(EventHeader.NAME);
            if (eventHeaderValid(request, ev_hdr) == false)
            {
                // 489 Bad Event, debug msg already output
                Response response = getMessageFactory().createResponse(
                        Response.BAD_EVENT, request);
                sendResponse(event, response);
                return;
            }

            if (ev_hdr.getEventType().equals("presence.winfo") == true)
            {
                // watcher info placeholder - we don't support this package
                Response response = getMessageFactory().createResponse(
                        Response.BAD_EVENT, request);
                sendResponse(event, response);
                return;
            }

            // determine the duration
            int duration = DEFAULT_SUBSCRIBE_DURATION;
            ExpiresHeader exp = (ExpiresHeader) request
                    .getHeader(ExpiresHeader.NAME);
            if (exp != null)
            {
                duration = exp.getExpires();
            }

            // find the active subscription (if exists) for this message
            Subscription sub = subscriptionList.findSubscription(request);

            if (sub != null)
            {
                if (duration > 0)
                {
                    refresh(event, sub, duration);
                    return;
                }

                // this is an unsubscribe
                try
                {
                    unsubscribe(event, sub, duration);
                }
                catch (Exception e)
                {
                    error("A SUBSCRIBE message could not be processed because an exception occured.\n"
                            + e.getClass().getName()
                            + ": "
                            + e.getMessage()
                            + "\n" + JipletLogger.getStackTrace(e));
                }

                // drop the subscription
                subscriptionList.removeSubscription(sub);
                sub.dispose();

                return;
            }

            // new subscription

            int response_code = Response.OK;
            String reason = "OK";
            String state = SubscriptionStateHeader.ACTIVE;

            // send the response right away
            String to_tag = new Long(Calendar.getInstance().getTimeInMillis())
                    .toString();
            Response response = createResponse(response_code, reason, to_tag,
                    request, duration);
            ServerTransaction transaction = sendResponse(event, response);

            if (transaction == null)
            {
                // stack couldn't give us a dialog
                return;
            }
            Dialog dialog = transaction.getDialog();

            sub = new Subscription(this, subscriptionList, SubscriptionList
                    .getSubscriptionId(request), ev_hdr.getEventId(), ev_hdr
                    .getEventType(), ((FromHeader) request
                    .getHeader(FromHeader.NAME)).getAddress(),
                    ((ToHeader) request.getHeader(ToHeader.NAME)).getAddress(),
                    to_tag);
            sub.setDialog(dialog);
View Full Code Here

TOP

Related Classes of javax.sip.header.EventHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.