コード例 #1
1
 public void Execute()
 {
     ChatHub chat = new ChatHub();
     chat.Send("ll", "dafjsd;fajsd;fjas;df");
 }
コード例 #2
0
ファイル: Startup.cs プロジェクト: olegtar83/signalR-exercise
        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);
        }
コード例 #3
0
ファイル: UnitTest.cs プロジェクト: djangojazz/SignalRTesting
 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);
 }
コード例 #4
0
        //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);
                }
            }
        }
コード例 #5
0
 //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
     }
 }
コード例 #6
0
 private static void RePollLoopExecute(object sender, ElapsedEventArgs e, ChatHub ch)
 {
     ch.pollProcess();
 }
コード例 #7
0
 private static void RePollLoopExecute(object sender, ElapsedEventArgs e, ChatHub ch)
 {
     ch.pollProcess();
 }
コード例 #8
0
        //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);
                }
            }

        }