disconnect client from server side signalr

后端 未结 6 1322
梦如初夏
梦如初夏 2021-02-19 06:39

I\'m using SignalR 1 with MVC4 C# web application with form authentication. I have a code in my layout page in JavaScript :

$(documnet).ready(function(){
               


        
6条回答
  •  余生分开走
    2021-02-19 07:09

    One way you could do what you ask is to write a disconnect event on your client that the server can call through SignalR. Maybe something somewhat like this:

    myHub.client.serverOrderedDisconnect = function (value) {
        $.connection.hub.stop();
    };
    

    Then, on the server, something like this:

    Clients.Client(Context.ConnectionId).serverOrderedDisconnect();
    

提交回复
热议问题