From: Vásáry Dániel Date: Thu, 22 Feb 2024 23:10:08 +0000 (+0100) Subject: WS archive client first look X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=de8bf98dd26305fa8069d320347ff4414b5af07c;p=mediacube.git WS archive client first look --- diff --git a/client/IntegrationTests/App.config b/client/IntegrationTests/App.config index acd65b49..7cf8d2bb 100644 --- a/client/IntegrationTests/App.config +++ b/client/IntegrationTests/App.config @@ -54,6 +54,10 @@ + + + + diff --git a/client/IntegrationTests/IntegrationTests.csproj b/client/IntegrationTests/IntegrationTests.csproj index a2503bc4..7b6e2e5c 100644 --- a/client/IntegrationTests/IntegrationTests.csproj +++ b/client/IntegrationTests/IntegrationTests.csproj @@ -136,7 +136,9 @@ ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - + + ..\packages\websocket-sharp-latest.1.0.2\lib\netstandard2.0\websocket-sharp-latest.dll + @@ -151,7 +153,8 @@ - PreserveNewest + Always + Designer diff --git a/client/IntegrationTests/JobEngineIT.cs b/client/IntegrationTests/JobEngineIT.cs index ffe0859e..9804539b 100644 --- a/client/IntegrationTests/JobEngineIT.cs +++ b/client/IntegrationTests/JobEngineIT.cs @@ -1,4 +1,5 @@ -using MaestroShared.Model; +using MaestroShared.Configuration; +using MaestroShared.Model; using MediaCubeClient; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; @@ -75,9 +76,14 @@ namespace IntegrationTests { } [TestMethod] - public void TestNotify() { - MediaCubeApi client = new MediaCubeApi("http://localhost:8080/services/rest/jobengine/", null, null, 100, null); - client.Notify("vasay@elgekko.net", null, "Újravágást kérek!"); + public void TestArchiveWSApi() { + Connection connection = new Connection { + Address = new Uri("ws://localhost:9080/services/wsapi-archive"), + Timeout = 5000 + }; + MediaCubeArchiveWSApi client = new MediaCubeArchiveWSApi(connection); + var message = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26 }; + client.Submit(message); } } diff --git a/client/IntegrationTests/nlog.config b/client/IntegrationTests/nlog.config index 4fed02b5..a4f110a9 100644 --- a/client/IntegrationTests/nlog.config +++ b/client/IntegrationTests/nlog.config @@ -3,14 +3,12 @@ - - - + + - - - + + diff --git a/client/IntegrationTests/packages.config b/client/IntegrationTests/packages.config index 351b7b27..3a4ae29e 100644 --- a/client/IntegrationTests/packages.config +++ b/client/IntegrationTests/packages.config @@ -17,4 +17,5 @@ + \ No newline at end of file diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 63600b00..0b71a1d6 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -181,7 +181,9 @@ - + + ..\packages\websocket-sharp-latest.1.0.2\lib\netstandard2.0\websocket-sharp-latest.dll + diff --git a/client/Maestro/packages.config b/client/Maestro/packages.config index 8df054a4..86a8bcfb 100644 --- a/client/Maestro/packages.config +++ b/client/Maestro/packages.config @@ -13,4 +13,5 @@ + \ No newline at end of file diff --git a/client/MaestroShared/Configuration/ConfigurationInfo.cs b/client/MaestroShared/Configuration/ConfigurationInfo.cs index 0abf1da9..7d73da28 100644 --- a/client/MaestroShared/Configuration/ConfigurationInfo.cs +++ b/client/MaestroShared/Configuration/ConfigurationInfo.cs @@ -216,6 +216,7 @@ namespace MaestroShared.Configuration { public string MetadataTitleFormat { get; set; } public string MetadataIDFormat { get; set; } public Connection WSServer { get; set; } + public Connection WSArchiveServer { get; set; } public string JobTemplate { get; set; } public int KillDateDays { get; set; } public Uri ArchiveFolder { get; set; } diff --git a/client/MediaCubeClient/MediaCubeArchiveWSApi.cs b/client/MediaCubeClient/MediaCubeArchiveWSApi.cs new file mode 100644 index 00000000..7a438773 --- /dev/null +++ b/client/MediaCubeClient/MediaCubeArchiveWSApi.cs @@ -0,0 +1,54 @@ +using MaestroShared.Configuration; +using NLog; +using System; +using System.IO; +using WebSocketSharp; + +namespace MediaCubeClient { + + public class MediaCubeArchiveWSApi { + private const string DATEFORMAT = "yyyy'-'MM'-'dd'T'HH':'mm':'ssK"; + private static NLog.Logger logger = LogManager.GetCurrentClassLogger(); + private readonly Connection connection; + private WebSocket ws; + + public MediaCubeArchiveWSApi(Connection connection) { + this.connection = connection; + } + + public void Submit(byte[] message) { + + try { + ws = new WebSocket(connection.Address.ToString()) { + WaitTime = TimeSpan.FromMilliseconds(connection.Timeout) + }; + + //ws.SslConfiguration.ServerCertificateValidationCallback = (s, c, ch, e) => { + // return true; + //}; + ws.OnMessage += (s, e) => { + logger.Info(e.Data); + }; + ws.OnError += (s, e) => { + ws.Close(); + logger.Info(e.Message); + }; + + ws.Connect(); + //ws.Send("valami.txt"); + //65536 + FileInfo fi = new FileInfo(@"c:\Downloads\Tajekoztatas_a_kamarai_hozzajarulas_fizetesi_hataridorol_2024.pdf"); + ws.Send(fi); + } catch (Exception e) { + logger.Error(e.Message); + } + } + + + public void Close() { + if (ws != null) + ws.Close(); + } + } + +} diff --git a/client/MediaCubeClient/MediaCubeClient.csproj b/client/MediaCubeClient/MediaCubeClient.csproj index 03a2b9e3..bfc8f66c 100644 --- a/client/MediaCubeClient/MediaCubeClient.csproj +++ b/client/MediaCubeClient/MediaCubeClient.csproj @@ -97,13 +97,13 @@ - - False - lib\websocket-sharp.dll + + ..\packages\websocket-sharp-latest.1.0.2\lib\netstandard2.0\websocket-sharp-latest.dll + diff --git a/client/MediaCubeClient/MediaCubeWSApi.cs b/client/MediaCubeClient/MediaCubeWSApi.cs index 32f8abad..8325afa3 100644 --- a/client/MediaCubeClient/MediaCubeWSApi.cs +++ b/client/MediaCubeClient/MediaCubeWSApi.cs @@ -137,7 +137,7 @@ namespace MediaCubeClient { barrier.SignalAndWait(); } catch (Exception e) { messageBus?.Send(new MediaCubeWSMessage($"Sikertelen MediaCube folyamatindítás. A rendszer üzenete: {e.Message}")); - } + } return result; } diff --git a/client/MediaCubeClient/packages.config b/client/MediaCubeClient/packages.config index 0693a580..d47178c2 100644 --- a/client/MediaCubeClient/packages.config +++ b/client/MediaCubeClient/packages.config @@ -4,4 +4,5 @@ + \ No newline at end of file