Example #1
0
        public override Task OnDisconnected(bool stopCalled)
        {
            if (balloons.Count(z => z.ConnectionId == Context.ConnectionId) == 1)
            {
                balloon itemLeaves = balloons.First(z => z.ConnectionId == Context.ConnectionId);

                string freeBalloon = itemLeaves.Name;
                balloons.Remove(itemLeaves);
                Clients.All.showBalloon(freeBalloon);
                if (console.Count > 0)
                {
                    foreach (string item in console)
                    {
                        Clients.Client(item).removePedina(freeBalloon);
                    }
                }
            }
            else if (console.Contains(Context.ConnectionId))
            {
                // remove connectionid from console
                console.Remove(Context.ConnectionId);
                if (console.Count == 0)
                {
                    resetGame();
                }
            }

            return(base.OnDisconnected(stopCalled));
        }
Example #2
0
        public async Task boomPedina(string name)
        {
            balloon itemLeaves  = balloons.First(z => z.Name == name);
            string  freeBalloon = name;

            balloons.Remove(itemLeaves);
            await Clients.Client(itemLeaves.ConnectionId).boomPedina();

            await Clients.All.showBalloon(freeBalloon);

            if (console.Count > 0)
            {
                foreach (string item in console)
                {
                    await Clients.Client(item).removePedina(freeBalloon);
                }
            }
        }