1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using org.doubango.tinyWRAP;
namespace test
{
class Program
{
public const String REALM = "open-ims.test";
public const String USER = "122";
public const String PROXY_CSCF_IP = "192.168.0.10";
public const ushort PROXY_CSCF_PORT = 5060;
public const String PASSWORD = "mamadou";
public const String SMSC = "123";
/*
const String REALM = "sip2sip.info";
const String USER = "2233392625";
const String PASSWORD = "d3sb7j4fb8";
const String PROXY_CSCF_IP = "192.168.0.13";
const uint PROXY_CSCF_PORT = 5081;
*/
static void Main(string[] args)
{
Boolean success;
/* Create callbacks */
sipCallback = new MySipCallback();
msrpCallback = new MyMsrpCallback();
//sipDebugCallback = new MySipDebugCallback();
/* Create consumers */
audioConsumer = new MyProxyAudioConsumer();
videoConsumer = new MyProxyVideoConsumer(tmedia_chroma_t.tmedia_rgb565le);
/* Create producers */
audioProducer = new MyProxyAudioProducer();
videoProducer = new MyProxyVideoProducer(tmedia_chroma_t.tmedia_rgb24);
/* Create and configure the IMS/LTE stack */
sipStack = new SipStack(sipCallback, String.Format("sip:{0}", REALM), /*String.Format("{0}@{1}", USER, REALM)*/USER, String.Format("sip:{0}@{1}", USER, REALM));
sipStack.setDebugCallback(sipDebugCallback);
sipStack.addHeader("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER");
sipStack.addHeader("Privacy", "header; id");
sipStack.addHeader("P-Access-Network-Info", "ADSL;utran-cell-id-3gpp=00000000");
sipStack.addHeader("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0");
/* Do it after stack creation */
ProxyAudioConsumer.registerPlugin();
ProxyAudioProducer.registerPlugin();
ProxyVideoProducer.registerPlugin();
ProxyVideoConsumer.registerPlugin();
/* Sets Proxy-CSCF */
success = sipStack.setProxyCSCF(PROXY_CSCF_IP, PROXY_CSCF_PORT, "udp", "ipv4");
// STUN
//sipStack.setSTUNServer("numb.viagenie.ca", 3478);
//sipStack.setSTUNCred("login", "password");
// DNS Discovery
//sipStack.setDnsDiscovery(true);
/* Starts the stack */
success = sipStack.start();
/* Set Password */
sipStack.setPassword(PASSWORD);
/* Early IMS */
sipStack.setEarlyIMS(true);
/* AMF and Operator Id */
sipStack.setAMF("0x00FF");
sipStack.setOperatorId("0xFF0000000000000000000000000000FF");
// SigComp
//sipStack.addSigCompCompartment("urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a876");
//sipStack.setAoR("127.0.0.1", 1234);
audioConsumer.setActivate(true);
audioProducer.setActivate(true);
videoProducer.setActivate(true);
videoConsumer.setActivate(true);
/* Send REGISTER */
regSession = new RegistrationSession(sipStack);
regSession.addCaps("+g.oma.sip-im");
regSession.addCaps("+g.3gpp.smsip");
regSession.addCaps("language", "\"en,fr\"");
regSession.setExpires(350);
//regSession.addSigCompCompartment("urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a876");
regSession.register_();
Console.ReadLine();
ActionConfig actionConfig = new ActionConfig();
actionConfig
.setMediaString(twrap_media_type_t.twrap_media_msrp, "file-path", "C:\\Users\\root\\Desktop\\Debian.iso")
//.setMediaString(twrap_media_type_t.twrap_media_msrp, "file-path", "C:\\avatar.png")
.setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", "application/octet-stream")
.setMediaString(twrap_media_type_t.twrap_media_msrp, "file-disposition", "attachment")
.setMediaString(twrap_media_type_t.twrap_media_msrp, "file-icon", "cid:test@doubango.org")
.setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", 500);
MsrpSession msrpSession = new MsrpSession(sipStack, msrpCallback);
msrpSession.callMsrp(String.Format("sip:johndoe@{0}", REALM), actionConfig);
actionConfig.Dispose();
Console.ReadLine();
msrpSession.hangup();
Console.ReadLine();
//RPMessage rpMessage = SMSEncoder.encodeDeliver(25, SMSC, "123456789", "salut comment tu vas?\n hdjdhfjfhfjhr, ");
//if (rpMessage != null)
//{
// uint pay_len = rpMessage.getPayloadLength();
// if (pay_len > 0)
// {
// byte[] pay = new byte[pay_len];
// rpMessage.getPayload(pay, (uint)pay.Length);
// MessagingSession m = new MessagingSession(sipStack);
// m.setToUri(String.Format("sip:{0}@{1}", SMSC, REALM));
// m.addHeader("Content-Type", "application/vnd.3gpp.sms");
// m.addHeader("Content-Transfer-Encoding", "binary");
// m.addHeader("P-Asserted-Identity", String.Format("sip:{0}@{1}", USER, REALM));
// m.send(pay, (uint)pay.Length);
// m.Dispose();
// }
// rpMessage.Dispose();
//}
//Console.ReadLine();
//String sipUri = sipStack.dnsENUM("E2U+SIP", "+1-800-555-5555", "e164.org");
//ushort port = 0;
//String ipAddress = sipStack.dnsNaptrSrv("sip2sip.info", "SIP+D2U", out port);
//String ipAddress = sipStack.dnsSrv("_sip._udp.sip2sip.info", out port);
/*ActionConfig actionConfig = new ActionConfig();
actionConfig.setMediaInt(twrap_media_type_t.twrap_media_audiovideo, "bandwidth-level", (int)tmedia_bandwidth_level_t.tmedia_bl_medium);
callSession = new CallSession(sipStack);
callSession.set100rel(true);
callSession.setSessionTimer(90, "uas");
callSession.setQoS(tmedia_qos_stype_t.tmedia_qos_stype_segmented, tmedia_qos_strength_t.tmedia_qos_strength_optional);
callSession.callVideo(String.Format("sip:bob@{0}", REALM), actionConfig);
actionConfig.Dispose();*/
//tcb = new TimerCallback(OnTimer);
//timer = new Timer(tcb, new AutoResetEvent(false), 0, 20);
//Console.ReadLine();
//callSession.sendDTMF(1);
//Console.ReadLine();
//callSession.sendDTMF(2);
//Console.ReadLine();
//callSession.sendDTMF(11);
//Console.ReadLine();
////Console.ReadLine();
////callSession.hold();
////Console.ReadLine();
////callSession.resume();
//Console.ReadLine();
//callSession.hangup();
////Thread.Sleep(2000);
/*RPData rpdata = SMSEncoder.encodeSubmit(25, "+33160188661", "+33660188661", "salut");
if (rpdata != null)
{
uint pay_len = rpdata.getPayloadLength();
if (pay_len > 0)
{
byte[] pay = new byte[pay_len];
rpdata.getPayload(pay, (uint)pay.Length);
MessagingSession m = new MessagingSession(sipStack);
m.setToUri(String.Format("sip:+33160188661@{0}", REALM));
m.addHeader("Content-Type", "application/vnd.3gpp.sms");
m.addHeader("Transfer-Encoding", "binary");
m.send(pay, (uint)pay.Length);
m.Dispose();
}
rpdata.Dispose();
}
Console.ReadLine();*/
///* Send SUBSCRIBE(reg) */
//subSession = new SubscriptionSession(sipStack);
//subSession.addHeader("Event", "reg");
//subSession.addHeader("Accept", "application/reginfo+xml");
//subSession.addHeader("Allow-Events", "refer, presence, presence.winfo, xcap-diff, conference");
//subSession.setExpires(35);
////subSession.Subscribe();
///* Send MESSAGE */
//MessagingSession msg = new MessagingSession(sipStack);
//byte [] content = Encoding.ASCII.GetBytes("Hello World");
//msg.setToUri(String.Format("sip:{0}@{1}", "alice", REALM));
//msg.addHeader("NS", "imdn <urn:ietf:params:imdn>");
//msg.addHeader("imdn.Message-ID", "34jk324j");
//msg.addHeader("DateTime", "2006-04-04T12:16:49-05:00");
//msg.addHeader("imdn.Disposition-Notification", "positive-delivery, negative-delivery");
//msg.addHeader("Content-Type", "text/plain");
////msg.Send(content, (uint)content.Length);
///* Send OPTIONS */
//OptionsSession opt = new OptionsSession(sipStack);
//opt.setToUri(String.Format("sip:{0}@{1}", "hacking_the_aor", REALM));
//opt.Send();
Console.ReadLine();
sipStack.stop();
}
public static void OnTimer(Object stateInfo)
{
//byte[] bytesAudio = new byte[320];
//uint ret = audioConsumer.pull(bytesAudio, (uint)bytesAudio.Length);
//Console.WriteLine("pull="+ret);
//int ret2 = audioProducer.push(bytesAudio, (uint)bytesAudio.Length);
//Console.WriteLine("push=" + ret);
//byte[] bytesVideo = new byte[176*144*3];
//int ret3 = videoProducer.push(bytesVideo, (uint)bytesVideo.Length);
}
static Timer timer;
static TimerCallback tcb;
static CallSession callSession;
static RegistrationSession regSession;
static SubscriptionSession subSession;
public static MyMsrpCallback msrpCallback;
static MySipCallback sipCallback;
public static SipStack sipStack;
static MySipDebugCallback sipDebugCallback;
static MyProxyAudioConsumer audioConsumer;
static MyProxyAudioProducer audioProducer;
static MyProxyVideoProducer videoProducer;
public static MyProxyVideoConsumer videoConsumer;
}
public class MySipDebugCallback : DDebugCallback
{
public override int OnDebugInfo(string message)
{
Console.WriteLine(".NET____" + message);
return 0;
}
public override int OnDebugWarn(string message)
{
Console.WriteLine(".NET____" + message);
return 0;
}
public override int OnDebugError(string message)
{
Console.WriteLine(".NET____" + message);
return 0;
}
public override int OnDebugFatal(string message)
{
Console.WriteLine(".NET____" + message);
return 0;
}
}
public class MyProxyAudioConsumer : ProxyAudioConsumer
{
public override int prepare(int ptime, int rate, int channels)
{
return base.prepare(ptime, rate, channels);
}
public override int start()
{
return base.start();
}
public override int pause()
{
return base.pause();
}
public override int stop()
{
return base.stop();
}
}
public class MyProxyAudioProducer : ProxyAudioProducer
{
public override int prepare(int ptime, int rate, int channels)
{
return base.prepare(ptime, rate, channels);
}
public override int start()
{
return base.start();
}
public override int pause()
{
return base.pause();
}
public override int stop()
{
return base.stop();
}
}
public class MyProxyVideoProducer : ProxyVideoProducer
{
public MyProxyVideoProducer(tmedia_chroma_t chroma)
: base(chroma)
{
}
public override int prepare(int width, int height, int fps)
{
return base.prepare(width, height, fps);
}
public override int start()
{
return base.start();
}
public override int pause()
{
return base.pause();
}
public override int stop()
{
return base.stop();
}
}
public class MyProxyVideoConsumer : ProxyVideoConsumer
{
public MyProxyVideoConsumer(tmedia_chroma_t chroma)
: base(chroma)
{
}
public override int prepare(int width, int height, int fps)
{
return base.prepare(width, height, fps);
}
public override int start()
{
Program.videoConsumer.setDisplaySize(352, 288);
return base.start();
}
public override int consume(ProxyVideoFrame frame)
{
uint size = frame.getSize(); // for test
byte[] bytes = new byte[1200];
uint ret = frame.getContent(bytes, (uint)bytes.Length);
Program.videoConsumer.setDisplaySize(176, 144);
return 0;
}
public override int pause()
{
return base.pause();
}
public override int stop()
{
return base.stop();
}
}
public class MyMsrpCallback : MsrpCallback
{
public override int OnEvent(MsrpEvent e)
{
MsrpSession session = e.getSipSession();
MsrpMessage message = e.getMessage();
if (session != null && message != null)
{
uint id = session.getId();
//Console.WriteLine("Msrp Event {0} {1}", id, message.getMsrpHeaderValue("Byte-Range"));
long start, end, total;
//message.getByteRange(out start, out end, out total);
//Console.WriteLine("Byte-Range {0}-{1}/{2}", start, end, total);
//if (message.isRequest())
// {
// uint size = message.getMsrpContentLength();
// byte[] bytes = new byte[(int)size];
// message.getMsrpContent(bytes, (uint)bytes.Length);
// }
if (!message.isRequest() && message.getCode() == 200)
{
if (message.isLastChunck())
{
session.hangup();
}
}
}
return 0;
}
}
public class MySipCallback : SipCallback
{
public MySipCallback()
: base()
{
}
public override int OnRegistrationEvent(RegistrationEvent e)
{
short code = e.getCode();
tsip_register_event_type_t type = e.getType();
RegistrationSession session = e.getSession();
SipMessage message = e.getSipMessage();
if (message != null)
{
Console.WriteLine("call-id={0}", message.getSipHeaderValue("call-id"));
//byte[] bytes = message.getContent();
}
switch (type)
{
case tsip_register_event_type_t.tsip_ao_register:
case tsip_register_event_type_t.tsip_ao_unregister:
break;
}
Console.WriteLine("OnRegistrationChanged() ==> {0}:{1}", code, e.getPhrase());
return 0;
}
public override int OnInviteEvent(InviteEvent e)
{
tsip_invite_event_type_t type = e.getType();
InviteSession session = e.getSession();
SipMessage message = e.getSipMessage();
switch(type){
case tsip_invite_event_type_t.tsip_i_newcall:
SdpMessage sdp = message.getSdpMessage();
if (session != null){
Console.WriteLine("ERRRRRRRRRRRORRRR");
return 0;
}
else{
switch(e.getMediaType()){
case twrap_media_type_t.twrap_media_audio:
case twrap_media_type_t.twrap_media_video:
case twrap_media_type_t.twrap_media_audiovideo:
session = e.takeCallSessionOwnership();
break;
case twrap_media_type_t.twrap_media_msrp:
if ((session = e.takeMsrpSessionOwnership()) != null){
(session as MsrpSession).setCallback(Program.msrpCallback);
}
break;
}
if(session != null){
ActionConfig actionConfig = new ActionConfig();
session.accept(actionConfig);
actionConfig.Dispose();
}
}
/*else if ((session = e.takeSessionOwnership()) != null)
{
SdpMessage sdp = message.getSdpMessage();
if (sdp != null)
{
String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");
Console.WriteLine("file-selector={0}", fileSelector);
}
ActionConfig actionConfig = new ActionConfig();
//actionConfig.setMediaInt(twrap_media_type_t.twrap_media_audiovideo, "bandwidth-level", (int)tmedia_bandwidth_level_t.tmedia_bl_low);
actionConfig.setMediaString(twrap_media_type_t.twrap_media_file, "file-path", "C:\\tmp\\myfile");
session.accept(actionConfig);
actionConfig.Dispose();
}*/
break;
case tsip_invite_event_type_t.tsip_i_request:
break;
case tsip_invite_event_type_t.tsip_ao_request:
break;
case tsip_invite_event_type_t.tsip_o_ect_ok:
break;
case tsip_invite_event_type_t.tsip_o_ect_nok:
break;
case tsip_invite_event_type_t.tsip_i_ect:
break;
case tsip_invite_event_type_t.tsip_m_local_hold_ok:
Console.WriteLine("Local Hold OK");
break;
case tsip_invite_event_type_t.tsip_m_local_hold_nok:
Console.WriteLine("Local Hold NOK");
break;
case tsip_invite_event_type_t.tsip_m_local_resume_ok:
Console.WriteLine("Local Resume OK");
break;
case tsip_invite_event_type_t.tsip_m_local_resume_nok:
Console.WriteLine("Local Resume NOK");
break;
case tsip_invite_event_type_t.tsip_m_remote_hold:
Console.WriteLine("Remote Hold");
break;
case tsip_invite_event_type_t.tsip_m_remote_resume:
Console.WriteLine("Remote Resume");
break;
}
return 0;
}
public override int OnOptionsEvent(OptionsEvent e)
{
short code = e.getCode();
tsip_options_event_type_t type = e.getType();
OptionsSession session = e.getSession();
SipMessage message = e.getSipMessage();
if (message != null)
{
Console.WriteLine("call-id={0}", message.getSipHeaderValue("call-id"));
//byte[] bytes = message.getContent();
}
switch (type)
{
case tsip_options_event_type_t.tsip_ao_options:
String rport = message.getSipHeaderParamValue("v", "rport");
String received_ip = message.getSipHeaderParamValue("v", "received");
if (rport == null)
{ /* Ericsson SDS */
rport = message.getSipHeaderParamValue("v", "received_port_ext");
}
Console.WriteLine("Via(rport, received)=({0}, {1})", rport, received_ip);
break;
case tsip_options_event_type_t.tsip_i_options:
break;
}
Console.WriteLine("OnRegistrationChanged() ==> {0}:{1}", code, e.getPhrase());
return 0;
}
public override int OnMessagingEvent(MessagingEvent e)
{
short code = e.getCode();
tsip_message_event_type_t type = e.getType();
MessagingSession session = e.getSession();
SipMessage message = e.getSipMessage();
if (session == null && message != null)
{ /* "Server-side-session" e.g. Initial MESSAGE/INVITE sent by the remote party */
session = e.takeSessionOwnership();
}
//Console.WriteLine("From:{0} == To:{1}", message.getSipHeaderValue("f"), message.getSipHeaderValue("t"));
if (message == null)
{
return 0;
}
switch (type)
{
case tsip_message_event_type_t.tsip_i_message:
byte[] content = message.getSipContent();
if (content != null)
{
Console.WriteLine("Message Content ==> {0}", Encoding.UTF8.GetString(content));
session.accept();
String contentType = message.getSipHeaderValue("c");
if (contentType != null && contentType.Equals("application/vnd.3gpp.sms", StringComparison.InvariantCultureIgnoreCase))
{
SMSData smsData = SMSEncoder.decode(content, (uint)content.Length, false);
if (smsData != null)
{
twrap_sms_type_t smsType = smsData.getType();
if (smsType == twrap_sms_type_t.twrap_sms_type_rpdata)
{
uint payLength = smsData.getPayloadLength();
String P_Asserted_Identity = message.getSipHeaderValue("P-Asserted-Identity");
if (payLength > 0)
{
/* Send RP-ACK */
String destination = smsData.getOA();
RPMessage rpACK = SMSEncoder.encodeACK(smsData.getMR(), Program.SMSC, destination == null ? "123456789" : destination, false);
if (rpACK != null)
{
uint pay_len = rpACK.getPayloadLength();
if (pay_len > 0)
{
byte[] pay = new byte[pay_len];
rpACK.getPayload(pay, (uint)pay.Length);
//byte[] pay = Encoding.UTF8.GetBytes("\x03\x01\x41\x09\x01\x00\x01\x80\x01\x32\x42\x00\x69");
MessagingSession m = new MessagingSession(Program.sipStack);
m.setToUri(String.Format("sip:{0}@{1}", Program.SMSC, Program.REALM));
m.addHeader("Content-Type", "application/vnd.3gpp.sms");
m.addHeader("Content-Transfer-Encoding", "binary");
m.send(pay, (uint)pay.Length);
m.Dispose();
}
rpACK.Dispose();
}
/* Print payload */
byte[] payload = new byte[payLength];
smsData.getPayload(payload, (uint)payload.Length);
Console.WriteLine("SMS content ={0} and OA={1}", Encoding.UTF8.GetString(payload), smsData.getOA());
}
else
{
/* Send RP-ERROR */
/* payload is mandatory in RP-DATA messages */
/* Send RP-ACK */
String destination = smsData.getOA();
RPMessage rpError = SMSEncoder.encodeError(smsData.getMR(), Program.SMSC, destination == null ? "123456789" : destination, false);
if (rpError != null)
{
uint pay_len = rpError.getPayloadLength();
if (pay_len > 0)
{
byte[] pay = new byte[pay_len];
rpError.getPayload(pay, (uint)pay.Length);
MessagingSession m = new MessagingSession(Program.sipStack);
m.setToUri(String.Format("sip:{0}@{1}", Program.SMSC, Program.REALM));
m.addHeader("Content-Type", "application/vnd.3gpp.sms");
m.addHeader("Content-Transfer-Encoding", "binary");
m.send(pay, (uint)pay.Length);
m.Dispose();
}
rpError.Dispose();
}
}
}
}
}
}
else
{
session.reject();
}
break;
case tsip_message_event_type_t.tsip_ao_message:
break;
}
Console.WriteLine("OnMessagingEvent() ==> {0}:{1}", code, e.getPhrase());
return 0;
}
public override int OnSubscriptionEvent(SubscriptionEvent e)
{
short code = e.getCode();
tsip_subscribe_event_type_t type = e.getType();
SubscriptionSession session = e.getSession();
SipMessage message = e.getSipMessage();
switch (type)
{
case tsip_subscribe_event_type_t.tsip_ao_subscribe:
case tsip_subscribe_event_type_t.tsip_ao_unsubscribe:
break;
case tsip_subscribe_event_type_t.tsip_i_notify:
byte[] content = message.getSipContent();
if (content != null)
Console.WriteLine("Notify Content ==> {0}", Encoding.UTF8.GetString(content));
break;
}
Console.WriteLine("OnSubscriptioChanged() ==> {0}:{1}", code, e.getPhrase());
return 0;
}
const String PUBLISH_PAYLOAD = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<presence xmlns:cp=\"urn:ietf:params:xml:ns:pidf:cipid\" xmlns:caps=\"urn:ietf:params:xml:ns:pidf:caps\" xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" xmlns:pdm=\"urn:ietf:params:xml:ns:pidf:data-model\" xmlns:p=\"urn:ietf:params:xml:ns:pidf-diff\" xmlns:op=\"urn:oma:xml:prs:pidf:oma-pres\" entity=\"sip:bob@ims.inexbee.com\" xmlns=\"urn:ietf:params:xml:ns:pidf\">" +
"<pdm:person id=\"RPVRYNJH\">" +
"<op:overriding-willingness>" +
"<op:basic>open</op:basic>" +
"</op:overriding-willingness>" +
"<rpid:activities>" +
"<rpid:busy />" +
"</rpid:activities>" +
"<rpid:mood>" +
"<rpid:guilty />" +
"</rpid:mood>" +
"<cp:homepage>http://doubango.org</cp:homepage>" +
"<pdm:note>Come share with me RCS Experience</pdm:note>" +
"</pdm:person>" +
"<pdm:device id=\"d0001\">" +
"<status>" +
"<basic>open</basic>" +
"</status>" +
"<caps:devcaps>" +
"<caps:mobility>" +
"<caps:supported>" +
"<caps:fixed />" +
"</caps:supported>" +
"</caps:mobility>" +
"</caps:devcaps>" +
"<op:network-availability>" +
"<op:network id=\"IMS\">" +
"<op:active />" +
"</op:network>" +
"</op:network-availability>" +
"<pdm:deviceID>urn:uuid:3ca50bcb-7a67-44f1-afd0-994a55f930f4</pdm:deviceID>" +
"</pdm:device>" +
"</presence>";
}
}
|