Debian Codegraph @

Xpjproject/pjsip-apps/src/swig/csharp/sample.cs

raw symbols SCIP
1 /* $Id $ */
2 /*
3 * Copyright (C) 2018-2018 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 using System;
21 using pjsua2xamarin.pjsua2;
22
23 namespace pjsua2xamarin
24 {
25 public class MyAccount : Account
26 {
27 ~MyAccount()
28 {
29 Console.WriteLine("*** Account is being deleted");
30 }
31
32 override public void onRegState(OnRegStateParam prm)
33 {
34 AccountInfo ai = getInfo();
35 Console.WriteLine("***" + (ai.regIsActive? "": "Un") +
36 "Register: code=" + prm.code);
37 }
38 }
39
40 public class MyLogWriter : LogWriter
41 {
42 override public void write(LogEntry entry)
43 {
44 Console.WriteLine(entry.msg);
45 }
46 }
47
48 public class sample
49 {
50 public static Endpoint ep = new Endpoint();
51 public static MyLogWriter writer = new MyLogWriter();
52
53 public sample()
54 {
55 }
56
57 public void test1()
58 {
59 try {
60 ep.libCreate();
61
62 // Init library
63 EpConfig epConfig = new EpConfig();
64 epConfig.logConfig.writer = writer;
65 ep.libInit(epConfig);
66
67 // Create transport
68 TransportConfig tcfg = new TransportConfig();
69 tcfg.port = 5080;
70 ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP,
71 tcfg);
72 ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TCP,
73 tcfg);
74
75 // Start library
76 ep.libStart();
77 Console.WriteLine("*** PJSUA2 STARTED ***");
78
79 // Add account
80 AccountConfig accCfg = new AccountConfig();
81 accCfg.idUri = "sip:[email protected]";
82 accCfg.regConfig.registrarUri = "sip:sip.pjsip.org";
83 accCfg.sipConfig.authCreds.Add(
84 new AuthCredInfo("digest", "*", "test1", 0, "test1") );
85 MyAccount acc = new MyAccount();
86 acc.create(accCfg);
87
88 Console.WriteLine("*** DESTROYING PJSUA2 ***");
89 // Explicitly delete account when unused
90 acc.Dispose();
91 ep.libDestroy();
92 } catch (Exception err) {
93 Console.WriteLine("Exception: " + err.Message);
94 }
95 }
96 }
97 }