浏览代码

SignalR 3

leiy 1 年之前
父节点
当前提交
33ea5cdd70

+ 5 - 5
OASystem/OASystem.Api/Controllers/ClientHubController.cs

@@ -23,11 +23,11 @@ namespace OASystem.API.Controllers
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 获取所有的用户
+        /// 获取在线用户
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        [HttpGet("GetAllUserIds", Name = "GetAllUserIds")]
-        public List<UserModel> GetAllUserIds()
+        [HttpGet("GetOnlineUsers", Name = "GetOnlineUsers")]
+        public List<UserModel> GetOnlineUsers()
         {
         {
             return UserStore.OnlineUser;
             return UserStore.OnlineUser;
         }
         }
@@ -43,7 +43,7 @@ namespace OASystem.API.Controllers
         [HttpPost("SendAllUserMessage", Name = "SendAllUserMessage")]
         [HttpPost("SendAllUserMessage", Name = "SendAllUserMessage")]
         public async Task<IActionResult> SendAllUserMessage( string msg)
         public async Task<IActionResult> SendAllUserMessage( string msg)
         {
         {
-            await _hubContext.Clients.All.SendAll(msg);
+            await _hubContext.Clients.All.SendAsync("ReceiveMessage", msg);
             return Ok("Send Successful!");
             return Ok("Send Successful!");
         }
         }
 
 
@@ -65,7 +65,7 @@ namespace OASystem.API.Controllers
                 connId = user.ConnectionId;
                 connId = user.ConnectionId;
             }
             }
 
 
-            await _hubContext.Clients.Client(connId).SendCustomUserMessage(date);
+            await _hubContext.Clients.Client(connId).SendSystemToUser(date);
             return Ok("Send Successful!");
             return Ok("Send Successful!");
         }
         }
     }
     }

+ 0 - 1
OASystem/OASystem.Api/OAMethodLib/SignalR/Hubs/ChatHub.cs

@@ -126,7 +126,6 @@ namespace OASystem.API.OAMethodLib.Hub.Hubs
             await Clients.Caller.SendAll(_common.SendCaller(data));
             await Clients.Caller.SendAll(_common.SendCaller(data));
         }
         }
 
 
-
         /// <summary>
         /// <summary>
         /// 发送消息给指定用户(系统)
         /// 发送消息给指定用户(系统)
         /// </summary>
         /// </summary>