Example #1
1
 public void Execute()
 {
     ChatHub chat = new ChatHub();
     chat.Send("ll", "dafjsd;fajsd;fjas;df");
 }
Example #2
0
        public void Configuration(IAppBuilder app)
        {
            // Any connection or hub wire up and configuration should go here
            app.MapSignalR();
            var hub = new ChatHub();

            hub.CheckCache();
            var timer = new System.Threading.Timer((e) =>
            {
                hub.Chat();
            }, null, TimeSpan.Zero.Seconds, 1500);
        }
Example #3
0
 public void HubsAreMockableViaDynamic()
 {
     bool sendCalled = false;
     var hub = new ChatHub();
     var mockClients = new Mock<IHubCallerConnectionContext<dynamic>>();
     hub.Clients = mockClients.Object;
     dynamic all = new ExpandoObject();
     all.broadcastMessage = new Action<string, string>((name, message) =>
     {
         sendCalled = true;
     });
     mockClients.Setup(m => m.All).Returns((ExpandoObject)all);
     hub.Send("TestUser", "TestMessage");
     Assert.IsTrue(sendCalled);
 }
        //loops through all groups, sends update times to affected groups
        private static void CountDownLoopExecute(object sender, ElapsedEventArgs e, ChatHub ch)
        {
            if (CountDownQueue.Count > 0)
            {
                DebugOut("Countdown Execute - length is " + CountDownQueue.Count);
            }

            foreach (GameGroup gameGroup in CountDownQueue)
            {
                gameGroup.DecrementTimer();
                ch.Clients.Group(gameGroup.id).updateCountdown(gameGroup.countdownTime);
                if (gameGroup.countdownTime <= 0)   //if timer = 0 then dequeue this group
                {
                    GameGroup gg;
                    CountDownQueue.TryDequeue(out gg);
                }
            }
        }
 //overriden method will channel debugging dependent on type specified
 public static void DebugOut(string info, string type)
 {
     if (disableDebuggingComments)
     {
         return;
     }
     if (type == "debug")
     {
         ChatHub.DebugOut(info);
     }
     else if (type == "appHb")
     {
         Trace.TraceInformation(info); //app Harbour trace
     }
     else if (type == "log2console")
     {
         ChatHub.DebugOut(info);
     }
     else
     {
         ChatHub.DebugOut(info); //default override
     }
 }
 private static void RePollLoopExecute(object sender, ElapsedEventArgs e, ChatHub ch)
 {
     ch.pollProcess();
 }
 private static void RePollLoopExecute(object sender, ElapsedEventArgs e, ChatHub ch)
 {
     ch.pollProcess();
 }
        //loops through all groups, sends update times to affected groups
        private static void CountDownLoopExecute(object sender, ElapsedEventArgs e, ChatHub ch)
        {

            if (CountDownQueue.Count > 0) {
                DebugOut("Countdown Execute - length is " + CountDownQueue.Count);
            }

            foreach (GameGroup gameGroup in CountDownQueue) { 
                gameGroup.DecrementTimer();
                ch.Clients.Group(gameGroup.id).updateCountdown(gameGroup.countdownTime); 
                if (gameGroup.countdownTime <= 0) { //if timer = 0 then dequeue this group
                    GameGroup gg;
                    CountDownQueue.TryDequeue(out gg);
                }
            }

        }