01: package examples.publish;
02:
03: import javax.sip.*;
04: import javax.sip.address.*;
05: import javax.sip.header.*;
06: import javax.sip.message.*;
07:
08: public class Publisher implements SipListener {
09: SipProvider udpProvider;
10: HeaderFactory headerFactory;
11: MessageFactory messageFactory;
12:
13: class MyEventSource implements Runnable {
14: private Notifier notifier;
15:
16: private EventHeader eventHeader;
17:
18: public MyEventSource(Notifier notifier, EventHeader eventHeader) {
19: this .notifier = notifier;
20: this .eventHeader = eventHeader;
21: }
22:
23: public void run() {
24: try {
25: for (int i = 0; i < 1; i++) {
26:
27: Thread.sleep(1000);
28: Request request = this .notifier.dialog
29: .createRequest(Request.NOTIFY);
30: SubscriptionStateHeader subscriptionState = headerFactory
31: .createSubscriptionStateHeader(SubscriptionStateHeader.ACTIVE);
32: request.addHeader(subscriptionState);
33: request.addHeader(eventHeader);
34: ClientTransaction ct = udpProvider
35: .getNewClientTransaction(request);
36: this .notifier.dialog.sendRequest(ct);
37:
38: }
39: Request request = this .notifier.dialog
40: .createRequest(Request.NOTIFY);
41: SubscriptionStateHeader subscriptionState = headerFactory
42: .createSubscriptionStateHeader(SubscriptionStateHeader.TERMINATED);
43: request.addHeader(eventHeader);
44: request.addHeader(subscriptionState);
45: ClientTransaction ct = udpProvider
46: .getNewClientTransaction(request);
47: this .notifier.dialog.sendRequest(ct);
48: } catch (Exception ex) {
49: ex.printStackTrace();
50: System.exit(0);
51: }
52: }
53: }
54:
55: public void processRequest(RequestEvent requestEvent) {
56: // TODO Auto-generated method stub
57:
58: }
59:
60: public void processResponse(ResponseEvent responseEvent) {
61: // TODO Auto-generated method stub
62:
63: }
64:
65: public void processTimeout(TimeoutEvent timeoutEvent) {
66: // TODO Auto-generated method stub
67:
68: }
69:
70: public void processIOException(IOExceptionEvent exceptionEvent) {
71: // TODO Auto-generated method stub
72:
73: }
74:
75: public void processTransactionTerminated(
76: TransactionTerminatedEvent transactionTerminatedEvent) {
77: // TODO Auto-generated method stub
78:
79: }
80:
81: public void processDialogTerminated(
82: DialogTerminatedEvent dialogTerminatedEvent) {
83: // TODO Auto-generated method stub
84:
85: }
86:
87: private Publisher() {
88:
89: }
90:
91: public static void main(String[] args) {
92:
93: }
94:
95: }
|