@@ -16,6 +16,8 @@ public partial class MainProgram : Form
16
16
OBSWebsocket mainWebsocket = new OBSWebsocket ( ) ;
17
17
18
18
// Public variables
19
+ public string wsPort ;
20
+ public string wsAddress ;
19
21
public string source1 ;
20
22
public string source2 ;
21
23
public string source3 ;
@@ -63,17 +65,20 @@ private void Form1_Load(object sender, EventArgs e)
63
65
64
66
try
65
67
{
66
- mainWebsocket . Connect ( "ws://127.0.0.1:4444" , wsPassword ) ;
68
+
69
+ mainWebsocket . WSTimeout = TimeSpan . FromSeconds ( 1 ) ;
70
+ mainWebsocket . Connect ( "ws://" + wsAddress + ":" + wsPort , wsPassword ) ;
67
71
if ( mainWebsocket . IsConnected )
68
72
{
73
+
69
74
lastLiveScene = mainWebsocket . GetCurrentScene ( ) . Name ; //Initialize lastLiveScene at the current live scene
70
-
75
+
71
76
//Update label text
72
77
label1 . Text = source1 ; label1 . Font = scaleFont ( label1 ) ;
73
78
label2 . Text = source2 ; label2 . Font = scaleFont ( label2 ) ;
74
79
label3 . Text = source3 ; label3 . Font = scaleFont ( label3 ) ;
75
80
label4 . Text = source4 ; label4 . Font = scaleFont ( label4 ) ;
76
-
81
+
77
82
RefreshLabels ( PreviewSceneSources , Color . Green ) ; //Set label colors for preview sources
78
83
RefreshLabels ( LiveSceneSources , Color . Red ) ; //Set label colors for live sources
79
84
}
@@ -85,8 +90,8 @@ private void Form1_Load(object sender, EventArgs e)
85
90
}
86
91
catch
87
92
{
88
-
89
93
}
94
+
90
95
}
91
96
92
97
// Main loop //
@@ -110,7 +115,7 @@ private void MainLoop(object sender, EventArgs e) // Loops continuously 100ms
110
115
////////////// LIVE //////////////
111
116
if ( currentLiveScene != lastLiveScene ) //If live scene state changes
112
117
{
113
- // Console.WriteLine("Live state has changed"); //Debugging
118
+ Console . WriteLine ( "Live state has changed" ) ; //Debugging
114
119
// Update live label colors for UI app
115
120
ColorAllLabels ( Color . Gray ) ; //Gray out all labels
116
121
if ( button2 . Text == "Previews ON" ) { RefreshLabels ( PreviewSceneSources , Color . Green ) ; } //Refresh preview labels
@@ -129,7 +134,7 @@ private void MainLoop(object sender, EventArgs e) // Loops continuously 100ms
129
134
// Update previews after prieview on/off is toggled
130
135
if ( lastbutton2State != button2_ClickCount )
131
136
{
132
- // Console.WriteLine("Previews on."); //Debugging
137
+ Console . WriteLine ( "Previews on." ) ; //Debugging
133
138
RefreshLabels ( PreviewSceneSources , Color . Green ) ; //Refresh preview labels
134
139
RefreshLabels ( LiveSceneSources , Color . Red ) ; //Set label colors for live sources
135
140
lastbutton2State = button2_ClickCount ; //Update lastbutton2State
@@ -141,7 +146,7 @@ private void MainLoop(object sender, EventArgs e) // Loops continuously 100ms
141
146
// Update preview label colors for UI app
142
147
if ( currentPreviewScene != lastPreviewScene ) //If preview scene state changes
143
148
{
144
- // Console.WriteLine("Preview state has changed"); //Debugging
149
+ Console . WriteLine ( "Preview state has changed" ) ; //Debugging
145
150
ColorAllLabels ( Color . Gray ) ; //Gray out all labels
146
151
RefreshLabels ( PreviewSceneSources , Color . Green ) ; //Set label colors for preview sources
147
152
RefreshLabels ( LiveSceneSources , Color . Red ) ; //Set label colors for live sources
@@ -158,7 +163,7 @@ private void MainLoop(object sender, EventArgs e) // Loops continuously 100ms
158
163
{
159
164
if ( lastbutton2State != button2_ClickCount ) // If preview on/off toggle changes
160
165
{
161
- // Console.WriteLine("Previews off."); //Debugging
166
+ Console . WriteLine ( "Previews off." ) ; //Debugging
162
167
ColorAllLabels ( Color . Gray ) ; //Gray out all labels
163
168
RefreshLabels ( LiveSceneSources , Color . Red ) ; //Refresh live labels
164
169
lastbutton2State = button2_ClickCount ; //Update lastbutton2State
@@ -200,8 +205,9 @@ private void WebsocketHeartbeat(object sender, EventArgs e) // Loops continuousl
200
205
messageShown = true ; // Set messageShown flag to true
201
206
DialogResult result = MessageBox . Show ( "Please verify the following:\n " +
202
207
"1. OBS is open and running.\n " +
203
- "2. OBS Websockets is installed and enabled.\n \n " +
204
- "Would you like to attempt to reconnect?" , "OBS TALLY: Lost connection to OBS" ,
208
+ "2. OBS Websockets is installed and enabled.\n " +
209
+ "3. You have entered the correct IP address and port.\n \n " +
210
+ "Would you like to attempt to reconnect? If not, click \" No\" , then run the setup again." , "OBS TALLY: Lost connection to OBS" ,
205
211
MessageBoxButtons . YesNo , MessageBoxIcon . Exclamation ) ;
206
212
if ( result == DialogResult . Yes )
207
213
{
@@ -210,7 +216,6 @@ private void WebsocketHeartbeat(object sender, EventArgs e) // Loops continuousl
210
216
}
211
217
else if ( result == DialogResult . No )
212
218
{
213
- this . Close ( ) ;
214
219
}
215
220
}
216
221
}
@@ -363,6 +368,10 @@ private void loadConfigXML()
363
368
source4 = fourth . Attributes [ "name" ] . Value ;
364
369
XmlNode wesPass = xmlDoc . SelectSingleNode ( "root/Websocket" ) ;
365
370
wsPassword = wesPass . Attributes [ "password" ] . Value ;
371
+ XmlNode wesPort = xmlDoc . SelectSingleNode ( "root/WebsocketPort" ) ;
372
+ wsPort = wesPort . Attributes [ "port" ] . Value ;
373
+ XmlNode wesAddress = xmlDoc . SelectSingleNode ( "root/WebsocketAddress" ) ;
374
+ wsAddress = wesAddress . Attributes [ "address" ] . Value ;
366
375
}
367
376
368
377
}
0 commit comments