diff --git a/server/.vs/ETS2 Local Radio desktop/v16/.suo b/server/.vs/ETS2 Local Radio desktop/v16/.suo index 091011ad4..fec788ae7 100644 Binary files a/server/.vs/ETS2 Local Radio desktop/v16/.suo and b/server/.vs/ETS2 Local Radio desktop/v16/.suo differ diff --git a/server/Capture/obj/Release/Capture.csproj.CoreCompileInputs.cache b/server/Capture/obj/Release/Capture.csproj.CoreCompileInputs.cache new file mode 100644 index 000000000..94c5b9598 --- /dev/null +++ b/server/Capture/obj/Release/Capture.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +294c31e6fff85af254053313cf06002d2cdbdb0f diff --git a/server/Capture/obj/Release/Capture.csproj.FileListAbsolute.txt b/server/Capture/obj/Release/Capture.csproj.FileListAbsolute.txt index 819ce3a2a..d59490227 100644 --- a/server/Capture/obj/Release/Capture.csproj.FileListAbsolute.txt +++ b/server/Capture/obj/Release/Capture.csproj.FileListAbsolute.txt @@ -13,3 +13,16 @@ F:\Mods\ETS2\ETS2 Map Capture Tool\ets2-local-radio\server\bin\EasyHook64Svc.exe F:\Mods\ETS2\ETS2 Map Capture Tool\ets2-local-radio\server\bin\EasyLoad32.dll F:\Mods\ETS2\ETS2 Map Capture Tool\ets2-local-radio\server\bin\EasyLoad64.dll F:\Mods\ETS2\ETS2 Map Capture Tool\ets2-local-radio\server\Capture\obj\Release\Capture.csprojAssemblyReference.cache +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\bin\EasyHook32.dll +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\bin\EasyHook64.dll +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\bin\EasyLoad32.dll +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\bin\EasyLoad64.dll +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\bin\EasyHook32Svc.exe +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\bin\EasyHook64Svc.exe +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\Capture\obj\Release\Capture.csprojAssemblyReference.cache +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\Capture\obj\Release\Capture.Properties.Resources.resources +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\Capture\obj\Release\Capture.csproj.GenerateResource.cache +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\Capture\obj\Release\Capture.csproj.CoreCompileInputs.cache +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\Capture\obj\Release\Capture.csproj.CopyComplete +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\Capture\obj\Release\Capture.dll +C:\Users\joshu\Documents\GitHub\ets2-local-radio\server\Capture\obj\Release\Capture.pdb diff --git a/server/Capture/obj/Release/Capture.csproj.GenerateResource.cache b/server/Capture/obj/Release/Capture.csproj.GenerateResource.cache index bacd0e618..a5808ec72 100644 Binary files a/server/Capture/obj/Release/Capture.csproj.GenerateResource.cache and b/server/Capture/obj/Release/Capture.csproj.GenerateResource.cache differ diff --git a/server/Capture/obj/Release/Capture.csprojAssemblyReference.cache b/server/Capture/obj/Release/Capture.csprojAssemblyReference.cache index 92251392a..095a15fdf 100644 Binary files a/server/Capture/obj/Release/Capture.csprojAssemblyReference.cache and b/server/Capture/obj/Release/Capture.csprojAssemblyReference.cache differ diff --git a/server/Capture/obj/Release/Capture.dll b/server/Capture/obj/Release/Capture.dll index c36534210..3590b909c 100644 Binary files a/server/Capture/obj/Release/Capture.dll and b/server/Capture/obj/Release/Capture.dll differ diff --git a/server/Capture/obj/Release/Capture.pdb b/server/Capture/obj/Release/Capture.pdb index 23147cdbe..c7c077289 100644 Binary files a/server/Capture/obj/Release/Capture.pdb and b/server/Capture/obj/Release/Capture.pdb differ diff --git a/server/ETS2 Local Radio desktop/ETS2 Local Radio desktop.csproj b/server/ETS2 Local Radio desktop/ETS2 Local Radio desktop.csproj index 9cd3297ea..f389365a0 100644 --- a/server/ETS2 Local Radio desktop/ETS2 Local Radio desktop.csproj +++ b/server/ETS2 Local Radio desktop/ETS2 Local Radio desktop.csproj @@ -68,7 +68,7 @@ - F:\Downloads\ets2-sdk-plugin-master\ets2-client\C#\Ets2SdkClient\bin\Release\Ets2SdkClient.dll + ..\plugins\Ets2SdkClient.dll ..\packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll diff --git a/server/ETS2 Local Radio desktop/SimpleServer.cs b/server/ETS2 Local Radio desktop/SimpleServer.cs index b7a45626b..6e54a6fb1 100644 --- a/server/ETS2 Local Radio desktop/SimpleServer.cs +++ b/server/ETS2 Local Radio desktop/SimpleServer.cs @@ -98,12 +98,24 @@ public class SimpleHTTPServer private string _rootDirectory; private HttpListener _listener; private int _port; + private string _radioSignal; public int Port { get { return _port; } private set { } } + public string RadioSignal + { + get { return _radioSignal; } + set { _radioSignal = value; } + } + private string _radioStation; + public string RadioStation + { + get { return _radioStation; } + set { _radioStation = value; } + } /// /// Construct server with given port. @@ -249,6 +261,8 @@ private void Process(HttpListenerContext context) try { Station.SetStation(station.Split("/".ToCharArray())[0], station.Split("/".ToCharArray())[1], station.Split("?".ToCharArray())[1]); + RadioStation = station.Split("/".ToCharArray())[0]; + RadioSignal = station.Split("/".ToCharArray())[1]; } catch (Exception) { @@ -273,6 +287,40 @@ private void Process(HttpListenerContext context) context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(text), 0, Encoding.UTF8.GetBytes(text).Length); context.Response.OutputStream.Flush(); } + else if (context.Request.Url.AbsolutePath == "/api/radio/") + { + string json = "{\"Radio\":\"" + RadioStation + "\",\"Signal\":\"" + RadioSignal + "\"}"; + context.Response.ContentType = "application/json"; + context.Response.ContentLength64 = Encoding.UTF8.GetBytes(json).Length; + context.Response.StatusCode = (int)HttpStatusCode.OK; + context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(json), 0, Encoding.UTF8.GetBytes(json).Length); + context.Response.OutputStream.Flush(); + } + else if (context.Request.Url.AbsolutePath.StartsWith("/api/radio/set/")) + { + string station = context.Request.Url.AbsoluteUri; + station = WebUtility.UrlDecode(station); + //station = station.Split(new string[] { "/station/" }, StringSplitOptions.None)[1]; + station = station.Split(new string[] { "/api/radio/set/" }, StringSplitOptions.None)[1]; + try + { + RadioSignal = station.Split("/".ToCharArray())[0]; + Console.WriteLine("Radio Signal: " + RadioSignal); + } + catch(Exception ex) + { + Console.WriteLine("Radio Signal: " + ex); + } + //RadioSignal = station; + + string text = "{\"Success\": true}"; + + context.Response.ContentType = "application/json"; + context.Response.ContentLength64 = Encoding.UTF8.GetBytes(text).Length; + context.Response.StatusCode = (int)HttpStatusCode.OK; + context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(text), 0, Encoding.UTF8.GetBytes(text).Length); + context.Response.OutputStream.Flush(); + } else if (context.Request.Url.AbsolutePath == "/commands/") { string text = Newtonsoft.Json.JsonConvert.SerializeObject(Main.commandsData); diff --git a/server/ETS2 Local Radio desktop/Station.cs b/server/ETS2 Local Radio desktop/Station.cs index eb5c1a792..50e7d373a 100644 --- a/server/ETS2 Local Radio desktop/Station.cs +++ b/server/ETS2 Local Radio desktop/Station.cs @@ -24,13 +24,14 @@ namespace ETS2_Local_Radio_server { - static class Station + public class Station { [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle); public struct Rect { + //public string RadioStation; public int Left { get; set; } public int Top { get; set; } public int Right { get; set; } @@ -38,8 +39,12 @@ public struct Rect } public static string NowPlaying = "Now playing:"; + public static bool RTL = false; + public static string RadioStation = "-"; + public static string RadioSignal = "1"; + public static int Width = 0; public static int Height = 0; @@ -48,6 +53,7 @@ public struct Rect public static System.Timers.Timer Timer = new System.Timers.Timer(); public static void SetStation(string name, string signal, string logoPath = null) + { try { @@ -62,7 +68,7 @@ public static void SetStation(string name, string signal, string logoPath = null return; } } - + Rect rectangle = new Rect(); GetWindowRect(CaptureProcess.Process.MainWindowHandle, ref rectangle); Width = rectangle.Right - rectangle.Left; @@ -94,6 +100,10 @@ public static void SetStation(string name, string signal, string logoPath = null var stringSize = g.MeasureString(NowPlaying + " " + name, font); var nowPlayingSize = g.MeasureString(NowPlaying + " ", font); + + RadioStation = name; + RadioSignal = signal; + var nameSize = g.MeasureString(name, font); var topLeft = new PointF((512 / 2) - (stringSize.Width / 2) + 123, (bmp.Height / 2) - (stringSize.Height / 2)); diff --git a/server/plugins/Ets2SdkClient.dll b/server/plugins/Ets2SdkClient.dll new file mode 100644 index 000000000..658f18d5d Binary files /dev/null and b/server/plugins/Ets2SdkClient.dll differ diff --git a/server/plugins/LICENSE.txt b/server/plugins/LICENSE.txt new file mode 100644 index 000000000..5205c327e --- /dev/null +++ b/server/plugins/LICENSE.txt @@ -0,0 +1,39 @@ +The MIT License (MIT) + +Copyright (c) 2014 Hans + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Copyright (c) 2015 Michael "MiKo" Koch, miko@mikoweb.de + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgement in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/server/plugins/README.txt b/server/plugins/README.txt new file mode 100644 index 000000000..8b4e10add --- /dev/null +++ b/server/plugins/README.txt @@ -0,0 +1,4 @@ +This folder contains the ETS2 SDK plugin by nlhans (https://github.com/nlhans/ets2-sdk-plugin) +Once you run ETS2 Local Radio for the first time, +it should automatically ask you for the ETS2 folder and copy the files. +If it does not work, please copy the plugins manually to the ETS2 installation folder. \ No newline at end of file diff --git a/server/plugins/alternative_ets2-telemetry.dll/ets2-telemetry.dll b/server/plugins/alternative_ets2-telemetry.dll/ets2-telemetry.dll new file mode 100644 index 000000000..6ac2cf86b Binary files /dev/null and b/server/plugins/alternative_ets2-telemetry.dll/ets2-telemetry.dll differ diff --git a/server/plugins/bin/win_x64/plugins/ets2-telemetry.dll b/server/plugins/bin/win_x64/plugins/ets2-telemetry.dll new file mode 100644 index 000000000..8e0404b5b Binary files /dev/null and b/server/plugins/bin/win_x64/plugins/ets2-telemetry.dll differ diff --git a/server/plugins/bin/win_x86/plugins/ets2-telemetry.dll b/server/plugins/bin/win_x86/plugins/ets2-telemetry.dll new file mode 100644 index 000000000..c6b2805c3 Binary files /dev/null and b/server/plugins/bin/win_x86/plugins/ets2-telemetry.dll differ diff --git a/web/lib/js/main.js b/web/lib/js/main.js index 42f0a3434..401c1a5a7 100644 --- a/web/lib/js/main.js +++ b/web/lib/js/main.js @@ -79,6 +79,7 @@ function initialise() { $.getJSON(g_api + "/api/", function (data) { refresh(data); }); + //$.post(g_api + "/api/radio/set/" + calculateReception(g_countries[country].whitenoise) + "/"); }, 1000); setInterval(function () { @@ -147,6 +148,7 @@ function initialise() { } } }); + $.post(g_api + "/api/radio/set/" + calculateReception(g_countries[g_current_country].whitenoise) + "/"); }, 250); $('#volumeControl').on("change mousemove", function () { @@ -295,8 +297,8 @@ function refresh(data) { if (Object.keys(available_countries).toString() != Object.keys(g_countries).toString()) { //If they don't contain the same keys (ie. a country update) g_countries = available_countries; - refreshStations(); + $.get(g_api + "/api/radio/set/" + calculateReception(g_countries[country].whitenoise) + "/"); /* for(var key in g_countries){ $.getJSON("/favourite/" + key, function (data) { @@ -306,6 +308,7 @@ function refresh(data) { */ } else { setWhitenoise(available_countries[g_current_country]["whitenoise"]); + $.get(g_api + "/api/radio/set/" + calculateReception(g_countries[country].whitenoise)+ "/"); g_countries = available_countries; }