1010using LiveSplit . Model ;
1111using LiveSplit . Model . Comparisons ;
1212using LiveSplit . Model . Input ;
13- using LiveSplit . Options ;
1413using LiveSplit . Racetime . Model ;
1514using LiveSplit . Web ;
16- using LiveSplit . Web . SRL ;
1715
1816namespace LiveSplit . Racetime . Controller
1917{
@@ -30,15 +28,11 @@ public static async Task RunPeriodically(Action action, TimeSpan period, Cancell
3028 }
3129 }
3230
33- public const string restProto = "http" ;
34- public const string wsProto = "ws" ;
35- public const string serverDomain = "192.168.178.70" ;
3631 public const int bufferSize = 20480 ;
3732 public const int maxBufferSize = 2097152 ;
38- public const int serverPort = 8000 ;
3933
40- public string FullWebRoot => string . Format ( "{0}://{1}:{2} /" , restProto , serverDomain , serverPort ) ;
41- public string FullSocketRoot => string . Format ( "{0}://{1}:{2} /" , wsProto , serverDomain , serverPort ) ;
34+ public string FullWebRoot => string . Format ( "{0}://{1}/" , Properties . Resources . PROTOCOL_REST , Properties . Resources . DOMAIN ) ;
35+ public string FullSocketRoot => string . Format ( "{0}://{1}/" , Properties . Resources . PROTOCOL_WEBSOCKET , Properties . Resources . DOMAIN ) ;
4236
4337 public Race Race { get ; set ; }
4438 public UserStatus PersonalStatus
@@ -70,7 +64,7 @@ public RacetimeChannel(LiveSplitState state, ITimerModel model)
7064 RunPeriodically ( ( ) => Reconnect ( ) , new TimeSpan ( 0 , 0 , 10 ) , reconnect_cts . Token ) ;
7165
7266
73- this . Model = model ;
67+ Model = model ;
7468
7569 state . OnSplit += State_OnSplit ;
7670 state . OnUndoSplit += State_OnUndoSplit ;
@@ -173,8 +167,8 @@ public async Task RunAsync(string id)
173167 {
174168 if ( await Authenticator . Authorize ( ) )
175169 {
176- Console . WriteLine ( Authenticator . Identity ) ;
177170 SendSystemMessage ( $ "Authorization successful. Hello, { Authenticator . Identity ? . Name } ") ;
171+ Authorized ? . Invoke ( this , null ) ;
178172 }
179173 else
180174 {
@@ -247,7 +241,6 @@ public async Task RunAsync(string id)
247241 }
248242 catch ( Exception ex )
249243 {
250- //Console.WriteLine(ex.InnerException.Message);
251244 }
252245 }
253246
@@ -345,7 +338,6 @@ private void UpdateRaceData(RaceMessage msg)
345338
346339 public IEnumerable < ChatMessage > Parse ( dynamic m )
347340 {
348- // Console.WriteLine(m.GetType().ToString() + m.ToString());
349341 switch ( m . type )
350342 {
351343 case "error" :
@@ -364,7 +356,6 @@ public IEnumerable<ChatMessage> Parse(dynamic m)
364356 RequestOutputReset ? . Invoke ( this , new EventArgs ( ) ) ;
365357 foreach ( var msg in m . messages )
366358 {
367- //Console.WriteLine(msg);
368359 if ( msg . user == null )
369360 yield return RTModelBase . Create < RaceBotMessage > ( msg ) ;
370361 else
@@ -424,6 +415,7 @@ private void State_OnSplit(object sender, EventArgs e)
424415 public event EventHandler UserListRefreshed ;
425416 public event EventHandlerT < IEnumerable < ChatMessage > > MessageReceived ;
426417 public event EventHandler RequestOutputReset ;
418+ public event EventHandler Authorized ;
427419
428420
429421
@@ -439,12 +431,16 @@ public void Disconnect()
439431 websocket_cts . Cancel ( ) ;
440432 reconnect_cts . Cancel ( ) ;
441433
434+ Authenticator . RevokeAccess ( ) ;
435+
442436 Model . Reset ( ) ;
443- // Model.CurrentState.Run.Clear() ;
437+ Model . CurrentState . Run . Offset = TimeSpan . Zero ;
444438 Model . OnPause -= Model_OnPause ;
445439 Model . OnSplit -= State_OnSplit ;
446440 Model . OnReset -= State_OnReset ;
447441 Model . OnUndoSplit -= State_OnUndoSplit ;
442+
443+
448444 }
449445
450446 public void Forfeit ( )
@@ -455,7 +451,7 @@ public void Forfeit()
455451
456452 public void RemoveRaceComparisons ( )
457453 {
458- Console . WriteLine ( "Remove Race Comparisons" ) ;
454+
459455 }
460456
461457 public bool TryCreateCommand ( ref string message )
@@ -466,7 +462,6 @@ public bool TryCreateCommand(ref string message)
466462 end = message . IndexOf ( ' ' ) <= 0 ? message . Length - 1 : message . IndexOf ( ' ' ) - 1 ;
467463
468464 var command = message . Substring ( 1 , end ) . TrimEnd ( ) . ToLower ( ) ;
469- //var parameter = message.Substring(message.IndexOf(' ')).TrimStart();
470465 message = "{ \" action\" : \" " + command + "\" }" ;
471466 return true ;
472467 }
0 commit comments