using ce.autofac.extension; using Infrastructure.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.SignalR.Client; namespace OpenAuth.App.BaseApp.ImMsgManager { public static class SendHubs { // // 摘要: // 调用hub方法 // // 参数: // methodName: // // args: // 参数 public static async Task callMethod(string imurl2, string imopen,string methodName, params object[] args) { if (imopen=="false") { return; } if (string.IsNullOrEmpty(imurl2)) { IHttpContextAccessor accessor = IocManager.Instance.GetService(); if (accessor.HttpContext != null) { imurl2 = accessor.HttpContext.Request.Host.Value; imurl2 = ((!accessor.HttpContext.Request.IsHttps) ? ("http://" + imurl2) : ("https://" + imurl2)); } } HubConnection connection = new HubConnectionBuilder().WithUrl(imurl2 + "/chathub").Build(); await connection.StartAsync(); await connection.InvokeCoreAsync(methodName, args); await connection.StopAsync(); } } }