| 1 |
*/ |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 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 |
|
| 63 |
EpConfig epConfig = new EpConfig(); |
| 64 |
epConfig.logConfig.writer = writer; |
| 65 |
ep.libInit(epConfig); |
| 66 |
|
| 67 |
|
| 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 |
|
| 76 |
ep.libStart(); |
| 77 |
Console.WriteLine("*** PJSUA2 STARTED ***"); |
| 78 |
|
| 79 |
|
| 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 |
|
| 90 |
acc.Dispose(); |
| 91 |
ep.libDestroy(); |
| 92 |
} catch (Exception err) { |
| 93 |
Console.WriteLine("Exception: " + err.Message); |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
} |