码迷,mamicode.com
首页 > 其他好文 > 详细

SignalR

时间:2021-06-02 11:56:01      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:false   tle   ==   flow   catch   消息推送   title   div   tar   

发送

namespace SignalR.Client
{
    public class ClientManage
    {
        public static readonly ClientManage Instance;

        private static IHubProxy proxy;
        static ClientManage()
        {
            Instance = new ClientManage();

            if (proxy == null)
            {
                string host = ConfigurationManager.AppSettings["SIGNALR_BASEURL"];
                if (!string.IsNullOrEmpty(host))
                {
                    HubConnection hubConn = new HubConnection(host + "signalr", false);
                    proxy = hubConn.CreateHubProxy("myHub");
                    hubConn.Start().Wait();

                }
            }
        }
        /// <summary>
        /// 流程消息推送
        /// </summary>
        /// <param name="appName">系统名称</param>
        /// <param name="approverId">审批人</param>
        /// <param name="msg">消息</param>
        /// <returns></returns>
        public void SendFlowMsg(string appName, string approverId, string msg)
        {
            try
            {
                if (proxy != null)
                    proxy.Invoke("sendFlowMsg", appName, approverId, msg);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void ReloadHomeApprovalList(string appName, string approverId)
        {
            try
            {
                if (proxy != null)
                    proxy.Invoke("sendReloadHomeApprovalList", appName, approverId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

调用

1: SignalR.Client.ClientManage.Instance.SendFlowMsg(SystemConfig.CONNECTION_TOKEN, receiverId, title);
2: public void ReloadApprovalList()
        {
            try
            {
                SignalR.Client.ClientManage.Instance.ReloadHomeApprovalList(SystemConfig.CONNECTION_TOKEN, "");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

 

SignalR

标签:false   tle   ==   flow   catch   消息推送   title   div   tar   

原文地址:https://www.cnblogs.com/ZkbFighting/p/14814643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!