1.1 --- a/Server/CecClient.cs Sun Jul 24 14:22:56 2016 +0200
1.2 +++ b/Server/CecClient.cs Sun Jul 24 20:36:07 2016 +0200
1.3 @@ -40,6 +40,11 @@
1.4 class Client : CecCallbackMethods
1.5 {
1.6 /// <summary>
1.7 + /// Enable public static access
1.8 + /// </summary>
1.9 + public static Client Static;
1.10 +
1.11 + /// <summary>
1.12 /// Provide direct access to CEC library
1.13 /// </summary>
1.14 public LibCecSharp Lib
1.15 @@ -91,8 +96,18 @@
1.16 iLib = new LibCecSharp(Config);
1.17 iLib.InitVideoStandalone();
1.18
1.19 + if (Static != null)
1.20 + {
1.21 + Console.WriteLine("WARNING: CEC client static already exists");
1.22 + }
1.23 + else
1.24 + {
1.25 + Static = this;
1.26 + }
1.27 +
1.28 +
1.29 //Console.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
1.30 - Console.WriteLine("CEC Parser created - libCEC version " + Config.ServerVersion);
1.31 + Console.WriteLine("INFO: CEC Parser created - libCEC version " + Config.ServerVersion);
1.32 }
1.33
1.34
1.35 @@ -114,7 +129,7 @@
1.36
1.37 Close();
1.38 //Try reconnect
1.39 - Connect(1000);
1.40 + Open(1000);
1.41 return 1;
1.42 }
1.43
1.44 @@ -203,13 +218,13 @@
1.45 /// </summary>
1.46 /// <param name="timeout"></param>
1.47 /// <returns></returns>
1.48 - public bool Connect(int timeout)
1.49 + public bool Open(int timeout)
1.50 {
1.51 Close();
1.52 CecAdapter[] adapters = iLib.FindAdapters(string.Empty);
1.53 if (adapters.Length > 0)
1.54 {
1.55 - Connect(adapters[0].ComPort, timeout);
1.56 + Open(adapters[0].ComPort, timeout);
1.57 }
1.58 else
1.59 {
1.60 @@ -219,15 +234,10 @@
1.61 return iConnected;
1.62 }
1.63
1.64 - public bool Connect(string port, int timeout)
1.65 + public bool Open(string port, int timeout)
1.66 {
1.67 Close();
1.68 iConnected = iLib.Open(port, timeout);
1.69 - if (iConnected)
1.70 - {
1.71 - Scan();
1.72 - //TestSendKey();
1.73 - }
1.74 return iConnected;
1.75 }
1.76
1.77 @@ -504,7 +514,7 @@
1.78 iLib.Close();
1.79
1.80 Console.WriteLine("opening a new connection");
1.81 - Connect(10000);
1.82 + Open(10000);
1.83
1.84 Console.WriteLine("setting active source");
1.85 iLib.SetActiveSource(CecDeviceType.PlaybackDevice);