• 00
  • :
  • 00
  • :
  • 00

SignalR记录

服务端检索数据库,有跟新,推送给客户端

1:  GlobalHost.ConnectionManager.GetHubContext<tvHub>().Clients.Client(Client.Key).sendMessage(UserHandler.dicGoods[roomid]);
 
winform或者其他 加载nuget包
 
public class tvDataShow
    {
        private IHubProxy HubProxy { get; set; }
        private HubConnection Connection { get; set; }

        public void SendMessage(string roomId,List<tvModel> data)
        {
            HubProxy.Invoke("sendMessage", roomId, data);
        }
        public void controllerConnected(string roomId)
        {
            HubProxy.Invoke("controllerConnected", roomId);
        }

        /// <summary>
        /// Creates and connects the hub connection and hub proxy. This method
        /// is called asynchronously from SignInButton_Click.
        /// </summary>
        public async void ConnectAsync(string ServerURI)
        {
            Connection = new HubConnection(ServerURI);
            HubProxy = Connection.CreateHubProxy("tvHub");
            try
            {
                await Connection.Start();
            }
            catch (HttpRequestException)
            {
                return;
            }
        }
    }
posted @ 2016-04-05 16:01  Garson_Zhang  阅读(379)  评论(0编辑  收藏  举报