-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
126 lines (105 loc) · 4.28 KB
/
Form1.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
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
using TrueConfVideoSDKLibrary;
using System.Net.NetworkInformation;
namespace ThreeVideoCallButtons
{
public partial class VideoCall : Form
{
public static readonly string VIDEOSDK_IP = "127.0.0.1";
public static readonly int VIDEOSDK_PORT = 8080;
public static readonly string VIDEOSDK_PIN = "";
public static readonly string TRUECONF_SERVER = "server.trueconf.com";
public static readonly string MY_ID = "kiosk";
public static readonly string MY_PASSWORD = "***";
// TrueConf IDs
public static readonly string TrueConfID1 = "operator1";
public static readonly string TrueConfID2 = "operator2";
public static readonly string TrueConfID3 = "operator3";
VideoSDK sdk;
int CurrentAppState = -1;
public VideoCall()
{
InitializeComponent();
sdk = new VideoSDK(true);
}
private void VideoCall_Load(object sender, EventArgs e)
{
InitSDK();
}
private void VideoCall_FormClosing(object sender, FormClosingEventArgs e)
{
sdk.CloseSession();
}
private void VideoCall_Shown(object sender, EventArgs e)
{
BackColor = Color.Lime;
TransparencyKey = Color.Lime;
FormBorderStyle = FormBorderStyle.None;
TopMost = true;
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
}
private void InitSDK()
{
sdk.OnAppStateChanged += OnStateChange;
sdk.Events.On_incomingChatMessage += OnEvent;
sdk.Methods.OnMethodResponse += OnMethod;
sdk.OnError += OnError;
// Connect to the VideoSDK instance trough Socket API
sdk.OpenSession(VIDEOSDK_IP, VIDEOSDK_PORT, VIDEOSDK_PIN);
Thread.Sleep(1000); // <<== It is just for this example. Don't do this anymore
sdk.Methods.connectToServer(TRUECONF_SERVER);
Thread.Sleep(1000); // <<== It is just for this example. Don't do this anymore
sdk.Methods.login(MY_ID, MY_PASSWORD);
Thread.Sleep(1000); // <<== It is just for this example. Don't do this anymore
}
private void OnStateChange(object source, AppStateChangedEventArgs appStateChangedEventArgs)
{
// Store the app state
CurrentAppState = appStateChangedEventArgs.NewState;
// Show the current application state
labelAppState.Text = AppStates.GetHint(appStateChangedEventArgs.NewState);
}
private void button1_Click(object sender, EventArgs e)
{
if (CurrentAppState == AppStates.Conference.State || CurrentAppState == AppStates.Wait.State)
sdk.Methods.hangUp();
else
sdk.Methods.call(TrueConfID1);
}
private void button2_Click(object sender, EventArgs e)
{
if (CurrentAppState == AppStates.Conference.State || CurrentAppState == AppStates.Wait.State)
sdk.Methods.hangUp();
else
sdk.Methods.call(TrueConfID2);
}
private void button3_Click(object sender, EventArgs e)
{
if (CurrentAppState == AppStates.Conference.State || CurrentAppState == AppStates.Wait.State)
sdk.Methods.hangUp();
else
sdk.Methods.call(TrueConfID3);
}
static void OnEvent(object source, string response)
{
var clr = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OnEvent: {0}", response);
Console.ForegroundColor = clr;
}
static void OnMethod(object source, string response)
{
var clr = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("OnMethod: {0}", response);
Console.ForegroundColor = clr;
}
static void OnError(object source, string message)
{
var clr = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("OnError: {0}", message);
Console.ForegroundColor = clr;
}
}
}