Exemplo n.º 1
0
        public async Task <ActionResult> LogOff()
        {
            string langs     = Request.Headers["Accept-Language"];
            var    callbacks = await ConnectionContext.UserConnectionClosed(User.Identity.GetUserId(), langs);

            // handle group chat ...
            {
                var gchub = new SignalRHubs.GroupChatHub();
                var nhub  = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <SignalRHubs.GroupChatHub>();
                if (nhub != null)
                {
                    foreach (var c in from d in callbacks where d.HubID == gchub.HubIdentity select d)
                    {
                        var peers = await GroupChatContext.ListConnectIds(gchub.HubIdentity, c.ChannelID);

                        if (peers.Length > 0)
                        {
                            var cids = (from d in peers select d.ConnectionID).ToArray();
                            nhub.Clients.Clients(cids).userDisConnected(GroupChatContext.GetJsonPeer(c));
                        }
                    }
                }
            }
            AuthenticationManager.SignOut();
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public override async Task OnDisconnected()
        {
            var cb = await ConnectionContext.OnUserDisconnected(HubIdentity, Context.ConnectionId);

            if (cb != null)
            {
                Clients.Client(cb.ChannelID).userDisConnected(GroupChatContext.GetJsonPeer(cb));
            }
            await base.OnDisconnected();
        }
Exemplo n.º 3
0
        public override async Task OnDisconnected()
        {
            var cb = await ConnectionContext.OnUserDisconnected(HubIdentity, Context.ConnectionId);

            var peers = await GroupChatContext.ListConnectIds(HubIdentity, cb.ChannelID);

            if (peers.Length > 0)
            {
                var cids = (from d in peers select d.ConnectionID).ToArray();
                Clients.Clients(cids).userDisConnected(GroupChatContext.GetJsonPeer(cb));
            }
            await base.OnDisconnected();
        }
Exemplo n.º 4
0
        public async Task UserConnected(string groupId)
        {
            var langs = Context.Request.Headers["Accept-Language"];
            var cb    = await GroupChatContext.UserConnected(HubIdentity, groupId, UserId, Context.ConnectionId, langs);

            var peers = await GroupChatContext.ListConnectIds(HubIdentity, groupId, true);

            if (peers.Length > 0)
            {
                var cids = (from d in peers select d.ConnectionID).ToArray();
                Clients.Clients(cids).userConnected(GroupChatContext.GetJsonPeer(cb));
            }
        }