-
Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathProgram.cs
101 lines (95 loc) · 3.66 KB
/
Program.cs
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
/*
* Copyright (c) 2005-2018, BearWare.dk
*
* Contact Information:
*
* Bjoern D. Rasmussen
* Kirketoften 5
* DK-8260 Viby J
* Denmark
* Email: [email protected]
* Phone: +45 20 20 54 59
* Web: http://www.bearware.dk
*
* This source code is part of the TeamTalk SDK owned by
* BearWare.dk. Use of this file, or its compiled unit, requires a
* TeamTalk SDK License Key issued by BearWare.dk.
*
* The TeamTalk SDK License Agreement along with its Terms and
* Conditions are outlined in the file License.txt included with the
* TeamTalk SDK distribution.
*
*/
using System;
using System.Collections.Generic;
using BearWare;
namespace TeamTalk5ProServer.NET
{
public class TeamTalkServer
{
String FILESTORAGE_FOLDER = "/tmp";
long MAX_DISKUSAGE = 1000000000, DEFAULT_CHANNEL_QUOTA = 10000000;
String ADMIN_USERNAME = "admin", ADMIN_PASSWORD = "admin";
String IPADDR = "127.0.0.1";
int TCPPORT = 10333, UDPPORT = 10333;
bool ENCRYPTED = false;
List<UserAccount> useraccounts = new List<UserAccount>();
public TeamTalkServer()
{
// Instantiate server
TeamTalk5Srv server = new TeamTalk5Srv();
server.SetEncryptionContext("", "");
if (server.SetChannelFilesRoot(FILESTORAGE_FOLDER, MAX_DISKUSAGE, DEFAULT_CHANNEL_QUOTA) != ClientError.SUCCESS)
{
Console.WriteLine("Failed to setup file sharing");
}
// create administrator user account
UserAccount useraccount = new UserAccount();
useraccount.szUsername = ADMIN_USERNAME;
useraccount.szPassword = ADMIN_PASSWORD;
useraccount.uUserType = UserType.USERTYPE_ADMIN;
useraccount.szNote = "An example administrator user account with all user-rights";
useraccount.uUserRights = UserRight.USERRIGHT_ALL;
useraccounts.Add(useraccount);
// Make root channel
Channel chan = new Channel();
chan.nChannelID = 1;
chan.nParentID = 0;
chan.nMaxUsers = 10;
chan.szName = "/";
chan.uChannelType = ChannelType.CHANNEL_PERMANENT;
chan.audiocodec = new AudioCodec();
chan.audiocfg = new AudioConfig(true);
// Subscribe Events
ServerCallback serverCallback = new ServerCallback(server, useraccounts);
ServerLogger logger = new ServerLogger(server);
ServerProperties srv = new ServerProperties();
srv.nUserTimeout = 200;
srv.nMaxUsers = 1000;
//Update Serverproperties
server.UpdateServer(srv);
if(server.MakeChannel(chan) != ClientError.SUCCESS)
{
Console.WriteLine("Failed to create root channel");
}
// Start server
if (!server.StartServer(IPADDR, TCPPORT, UDPPORT, ENCRYPTED))
{
Console.WriteLine("Failed to start server");
}
Console.Title = "TeamTalk Server v." + TeamTalk5Srv.GetVersion();
Console.WriteLine("Started TeamTalk {0} Server v.{1}\nTCP port: {2}, UDP port: {3}",
(ENCRYPTED? "Encrypted" : "Non-Encrypted"), TeamTalk5Srv.GetVersion(),
TCPPORT, UDPPORT);
//run server forever
while (server.RunEventLoop(0)) ;
}
}
class Program
{
static void Main(string[] args)
{
TeamTalkServer srv = new TeamTalkServer();
}
}
}