Ejemplo n.º 1
0
 public override Task OnDisconnected(bool stopCalled)
 {
     // Add your own code here.
     // For example: in a chat application, mark the user as offline,
     // delete the association between the current connection id and user name.
     SyncHub.SendMessage("Server", "Client disconnected");
     return(base.OnDisconnected(stopCalled));
 }
Ejemplo n.º 2
0
        public override Task OnConnected()
        {
            // Add your own code here.
            // For example: in a chat application, record the association between
            // the current connection ID and user name, and mark the user as online.
            // After the code in this method completes, the client is informed that
            // the connection is established; for example, in a JavaScript client,
            // the start().done callback is executed.

            //Hämta användarens namn ur requesten
            var name = Context.QueryString["username"];

            //Skicka meddelande om att personen anslutit.
            SyncHub.SendMessage("Server", $"{name} connected");

            //Skicka en uppdaterad lista till användarna.
            SendListUpdate();

            return(base.OnConnected());
        }