From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.SourceFactory/FormSignalR.cs |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/HotelPms.SourceFactory/FormSignalR.cs b/HotelPms.SourceFactory/FormSignalR.cs
new file mode 100644
index 0000000..3f23d70
--- /dev/null
+++ b/HotelPms.SourceFactory/FormSignalR.cs
@@ -0,0 +1,81 @@
+using HotelPms.Data.Common.Dtos;
+using Microsoft.AspNetCore.SignalR.Client;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace HotelPms.SourceFactory
+{
+    public partial class FormSignalR : Form
+    {
+        private HubConnection hubConnection;
+
+        public FormSignalR()
+        {
+            InitializeComponent();
+        }
+
+        private async void button1_Click(object sender, EventArgs e)
+        {
+            hubConnection = new HubConnectionBuilder()
+                //.WithUrl(NavigationManager.ToAbsoluteUri("/notifyhub"))
+                .WithUrl("https://localhost:44375/notifyhub")
+                .AddMessagePackProtocol()
+                .Build();
+
+            hubConnection.On<MessageDto>("ReceiveMessage", (data) =>
+            {
+                var encodedMsg = $"【{data.Id}】【{data.ConnectionId} ⇒ {data.DestConnectionId}】{data.Data};{data.Tag}";
+                listBox1.Items.Add(encodedMsg);
+
+                var options = new JsonSerializerOptions
+                {
+                    WriteIndented = true
+                };
+                string json = JsonSerializer.Serialize(data, options);
+                System.Diagnostics.Debug.WriteLine(json);
+            });
+
+            await hubConnection.StartAsync();
+            label1.Text = hubConnection.ConnectionId;
+        }
+
+        private async Task Send()
+        {
+            MessageDto dto = new MessageDto()
+            {
+                Id = Guid.NewGuid(),
+                UserID = "Client1",
+                Data = textBox1.Text,
+                Tag = "1000",
+            };
+            await hubConnection.SendAsync("SendMessage", dto);
+        }
+
+        public bool IsConnected =>
+            hubConnection.State == HubConnectionState.Connected;
+
+        public async ValueTask DisposeAsync()
+        {
+            await hubConnection.DisposeAsync();
+        }
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            _= Send();
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+
+        }
+    }
+}

--
Gitblit v1.10.0