public void Startup(bool debugMessages) { foreach (CloudBubble bubble in bubbles.Values) { bubble.Startup(); } hub.Startup(debugMessages); server.Startup(debugMessages); isStarted = true; }
public void Startup() { if (!IsAlive) { hub.Startup(); server.Startup(); foreach (TankBubble bubble in Bubbles) { bubble.Startup(); } thread = new Thread(new ThreadStart(Process)); thread.Start(); LogUtil.Info("Tank started."); } }
public void HubConnectionSuccess() { Guid sourceBubbleGuid = new Guid(); Guid targetBubbleGuid = new Guid(); MxpHub sourceHub = new MxpHub("http://test.cloud.url", "127.0.0.1", MxpConstants.DefaultHubPort, "TestServerProgram", 1, 2); MxpBubble sourceBubble = new MxpBubble(sourceBubbleGuid, "SourceBubbleName", 100, 1000); sourceHub.AddBubble(sourceBubble); Session sourceSession = null; sourceBubble.BubbleConnected += delegate(Session session, Message message) { sourceSession = session; }; sourceHub.Startup(false); MxpHub targetHub = new MxpHub("http://test.cloud.url", "127.0.0.1", MxpConstants.DefaultHubPort + 1, "TestServerProgram", 1, 2); MxpBubble targetBubble = new MxpBubble(targetBubbleGuid, "TargetBubbleName", 100, 1000); targetHub.AddBubble(targetBubble); Session targetSession = null; targetBubble.BubbleConnectAuthorize += delegate(Session session, AttachRequestMessage message) { return(true); }; targetBubble.BubbleConnected += delegate(Session session, Message message) { targetSession = session; }; targetHub.Startup(false); sourceHub.Connect(sourceBubbleGuid, targetBubbleGuid, "127.0.0.1", MxpConstants.DefaultHubPort + 1, 100, 100, 100); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Assert.IsNotNull(sourceSession); Assert.IsTrue(sourceSession.IsConnected); Assert.IsNotNull(targetSession); Assert.IsTrue(targetSession.IsConnected); Assert.AreEqual(1, sourceHub.SessionCount); Assert.AreEqual(1, targetHub.SessionCount); targetHub.Disconnect(targetSession); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Thread.Sleep(20); targetHub.Process(); Thread.Sleep(20); sourceHub.Process(); Assert.IsFalse(sourceSession.IsConnected); Assert.IsFalse(targetSession.IsConnected); Assert.AreEqual(0, sourceHub.SessionCount); Assert.AreEqual(0, targetHub.SessionCount); sourceHub.Shutdown(); targetHub.Shutdown(); }