Esempio n. 1
0
        private void UpdateCloud()
        {
            IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"];

            ILabelService labelService = container.Resolve <ILabelService>();

            DictionaryBlock <string, long> labelMap = labelService.GetMostValuedLabels(0, Settings.Default.WebMovies_labelsPerCloud);

            if (labelMap.Count == 0)
            {
                UpdateCloudFake();
                return;
            }
            double max = labelMap.Values.Max();
            double min = labelMap.Values.Min();

            SortedSet <ListItem> labels = new SortedSet <ListItem>(new AlphabeticalListItemTextComparer());

            foreach (string label in labelMap.Keys)
            {
                double rating  = labelMap[label];
                int    minSize = 30;
                if (max > min)
                {
                    minSize = (int)((rating - min) / (max - min) * 20.0 + 20.0);
                }
                ListItem listItem = new ListItem(label, minSize.ToString());
                labels.Add(listItem);
            }

            CloudView.DataSource = labels;
            CloudView.DataBind();
        }
Esempio n. 2
0
        public static void Main()
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            BasicConfigurator.Configure();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LogUtil.Info("Phase 0 - Startup begin.");

            SplashForm         = new SplashForm();
            SplashForm.Visible = true;
            Application.DoEvents();

            DeckPlayer.Play("boom");

            AssetManager = new AssetManager(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/BubbleCloud/Cache");
            CloudView    = new CloudView(100, DeckConstants.ProgramName, DeckConstants.ProgramMajorVersion, DeckConstants.ProgramMinorVersion);
            DeckEngine   = new DeckEngine();
            DeckRudder   = new DeckRudder();
            DeckRenderer = new DeckRenderer();

            DeckScene     = new DeckScene();
            DeckSelection = new DeckSelection();
            DeckDaemon    = new DeckDaemon();

            MainForm    = new MainForm();
            HudForm     = new HudForm();
            LoadingForm = new LoadingForm();
            LoginForm   = new LoginForm();

            MainForm.AddOwnedForm(SplashForm);
            MainForm.AddOwnedForm(HudForm);
            MainForm.AddOwnedForm(LoadingForm);
            MainForm.AddOwnedForm(LoginForm);

            AssetManager.Startup();

            LogUtil.Info("Phase 0 - Startup end.");
            LogUtil.Info("Phase 1 - Initialization begin.");

            MainLoop();

            LogUtil.Info("Shutdown begin.");
            while (CloudView.IsConnecting || CloudView.IsConnected)
            {
                CloudView.Disconnect();
                while (CloudView.IsConnected)
                {
                    CloudView.Process();
                    Thread.Sleep(10);
                }
            }
            AssetManager.Shutdown();
            DeckRenderer.Shutdown();
            LogUtil.Info("Shutdown done.");
        }
Esempio n. 3
0
        public BallDaemon(
            string serverAddress,
            int serverPort,
            Guid bubbleId,
            string daemonIdentifier,
            string daemonSecret
            )
        {
            this.serverAddress    = serverAddress;
            this.serverPort       = serverPort;
            this.bubbleId         = bubbleId;
            this.daemonIdentifier = daemonIdentifier;
            this.daemonSecret     = daemonSecret;
            String programName         = "Ball Daemon";
            byte   programMajorVersion = 0;
            byte   programMinorVersion = 1;

            client = new CloudView(100, programName, programMajorVersion, programMinorVersion);

            Random random = new Random();
            int    i      = 0;

            BallArray[i]                      = new BallObject();
            BallArray[i].ObjectId             = Guid.NewGuid();
            BallArray[i].ObjectName           = "Ball Daemon Avatar";
            BallArray[i].OrbitRadius          = 0;
            BallArray[i].OrbitAngle           = 0;
            BallArray[i].OrbitAngularVelocity = 0;
            BallArray[i].Location.X           = 0;
            BallArray[i].Location.Y           = 0;
            BallArray[i].Location.Z           = 0;
            Balls.Add(BallArray[i].ObjectId, BallArray[i]);

            for (i = 1; i < NumberOfObjects; i++)
            {
                BallArray[i]                      = new BallObject();
                BallArray[i].ObjectId             = Guid.NewGuid();
                BallArray[i].ObjectName           = "Test Object " + i;
                BallArray[i].OrbitRadius          = (float)(random.NextDouble() * 45) + 5;
                BallArray[i].OrbitAngle           = (float)(random.NextDouble() * 2 * Math.PI);
                BallArray[i].OrbitAngularVelocity = (float)(random.NextDouble() * 2 * Math.PI / 8);
                BallArray[i].Location.X           = (float)(BallArray[i].OrbitRadius * Math.Cos(BallArray[i].OrbitAngle));
                BallArray[i].Location.Y           = 0.5f;
                BallArray[i].Location.Z           = (float)(BallArray[i].OrbitRadius * Math.Sin(BallArray[i].OrbitAngle));
                Balls.Add(BallArray[i].ObjectId, BallArray[i]);
            }
        }
Esempio n. 4
0
        public DaemonParticipant(
            string serverAddress,
            int serverPort,
            Guid bubbleId,
            string daemonIdentifier,
            string daemonSecret
            )
        {
            this.serverAddress    = serverAddress;
            this.serverPort       = serverPort;
            this.bubbleId         = bubbleId;
            this.DaemonIdentifier = daemonIdentifier;
            this.DaemonSecret     = daemonSecret;
            String programName         = "Cloud Daemon Participant";
            byte   programMajorVersion = 0;
            byte   programMinorVersion = 1;

            bubble = QueryUtil.First <Bubble>((from b in entityContext.Bubble where b.BubbleId == bubbleId select b));

            Objects = (from o in entityContext.CloudObject where o.Bubble.BubbleId == bubble.BubbleId && o.Enabled == true select o).ToList <DaemonLogic.CloudObject>();

            lastRefreshTime = DateTime.Now;

            if (Objects.Count == 0)
            {
                return;
            }

            client = new CloudView(100, programName, programMajorVersion, programMinorVersion);

            client.ServerInteractRequest += OnInteractRequest;

            foreach (DaemonLogic.CloudObject cloudObject in Objects)
            {
                DaemonLogic.ObjectType  objectType  = QueryUtil.First <DaemonLogic.ObjectType>(from o in entityContext.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.ObjectType);
                DaemonLogic.Participant participant = QueryUtil.First <DaemonLogic.Participant>(from o in entityContext.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.Participant);
                IdObjectDictionary.Add(cloudObject.CloudObjectId, cloudObject);
            }
        }
        public static void Execute(string ip, int port)
        {
            log4net.Config.XmlConfigurator.Configure();

            CloudView view = null;

            try
            {
                string clientProgramName              = "ClientProgram";
                byte   clientProgramMajorVersion      = 5;
                byte   clientProgramMinorVersion      = 6;
                string participantIdentityProviderUrl = "http://test.identityprovider";
                string participantName       = "TestParticipantName";
                string participantPassphrase = "TestParticipantPassphrase";
                Guid   avatarId = new Guid("123DFA16-5B52-4c9f-9A09-AD7465208321");

                view = new CloudView(1000, clientProgramName, clientProgramMajorVersion, clientProgramMinorVersion);
                view.Connect(ip, port, new Guid("539DFA16-5B52-4c9f-9A09-AD746520873E"), "", "", participantIdentityProviderUrl, participantName, participantPassphrase, avatarId, true);

                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(100);
                    view.Process();
                    if (view.IsConnected)
                    {
                        break;
                    }
                }

                if (!view.IsConnected)
                {
                    Console.WriteLine("Unable to connect server.");
                    return;
                }

                Guid   objectId                           = avatarId;
                uint   objectIndex                        = 100;
                string objectName                         = "TestObjectName";
                Guid   objectParentObjectId               = Guid.NewGuid();
                Guid   objectTypeId                       = Guid.NewGuid();
                string objectTypeName                     = "TestObjectType";
                float  objectBoundingSphereRadius         = 23;
                float  objectMass                         = 24;
                float  objectLocationX                    = 2;
                float  objectLocationY                    = 3;
                float  objectLocationZ                    = 4;
                float  modifiedObjectLocationX            = 12;
                float  modifiedObjectLocationY            = 13;
                float  modifiedObjectLocationZ            = 14;
                float  objectVelocityX                    = 5;
                float  objectVelocityY                    = 6;
                float  objectVelocityZ                    = 7;
                float  objectAccelerationX                = 8;
                float  objectAccelerationY                = 9;
                float  objectAccelerationZ                = 10;
                float  objectOrientationX                 = 11;
                float  objectOrientationY                 = 12;
                float  objectOrientationZ                 = 13;
                float  objectOrientationW                 = 14;
                float  objectAngularVelocityX             = 15;
                float  objectAngularVelocityY             = 16;
                float  objectAngularVelocityZ             = 17;
                float  objectAngularVelocityW             = 18;
                float  objectAngularAccelerationX         = 19;
                float  objectAngularAccelerationY         = 20;
                float  objectAngularAccelerationZ         = 21;
                float  objectAngularAccelerationW         = 22;
                string objectExtensionDialect             = "TEDI";
                byte   objectExtensionDialectMinorVersion = 23;
                byte   objectExtensionDialectMajorVersion = 24;
                byte[] objectExtensionData                = ASCIIEncoding.ASCII.GetBytes("012345678901234567890123456789012345678901234567890123456789");

                InjectRequestMessage injectRequestMessage = new InjectRequestMessage();
                injectRequestMessage.ObjectFragment.ObjectId                     = objectId;
                injectRequestMessage.ObjectFragment.ObjectIndex                  = objectIndex;
                injectRequestMessage.ObjectFragment.ObjectName                   = objectName;
                injectRequestMessage.ObjectFragment.TypeId                       = objectTypeId;
                injectRequestMessage.ObjectFragment.TypeName                     = objectTypeName;
                injectRequestMessage.ObjectFragment.OwnerId                      = view.ParticipantId;
                injectRequestMessage.ObjectFragment.ParentObjectId               = objectParentObjectId;
                injectRequestMessage.ObjectFragment.Mass                         = objectMass;
                injectRequestMessage.ObjectFragment.BoundingSphereRadius         = objectBoundingSphereRadius;
                injectRequestMessage.ObjectFragment.Location.X                   = objectLocationX;
                injectRequestMessage.ObjectFragment.Location.Y                   = objectLocationY;
                injectRequestMessage.ObjectFragment.Location.Z                   = objectLocationZ;
                injectRequestMessage.ObjectFragment.Velocity.X                   = objectVelocityX;
                injectRequestMessage.ObjectFragment.Velocity.Y                   = objectVelocityY;
                injectRequestMessage.ObjectFragment.Velocity.Z                   = objectVelocityZ;
                injectRequestMessage.ObjectFragment.Acceleration.X               = objectAccelerationX;
                injectRequestMessage.ObjectFragment.Acceleration.Y               = objectAccelerationY;
                injectRequestMessage.ObjectFragment.Acceleration.Z               = objectAccelerationZ;
                injectRequestMessage.ObjectFragment.Orientation.X                = objectOrientationX;
                injectRequestMessage.ObjectFragment.Orientation.Y                = objectOrientationY;
                injectRequestMessage.ObjectFragment.Orientation.Z                = objectOrientationZ;
                injectRequestMessage.ObjectFragment.Orientation.W                = objectOrientationW;
                injectRequestMessage.ObjectFragment.AngularVelocity.X            = objectAngularVelocityX;
                injectRequestMessage.ObjectFragment.AngularVelocity.Y            = objectAngularVelocityY;
                injectRequestMessage.ObjectFragment.AngularVelocity.Z            = objectAngularVelocityZ;
                injectRequestMessage.ObjectFragment.AngularVelocity.W            = objectAngularVelocityW;
                injectRequestMessage.ObjectFragment.AngularAcceleration.X        = objectAngularAccelerationX;
                injectRequestMessage.ObjectFragment.AngularAcceleration.Y        = objectAngularAccelerationY;
                injectRequestMessage.ObjectFragment.AngularAcceleration.Z        = objectAngularAccelerationZ;
                injectRequestMessage.ObjectFragment.AngularAcceleration.W        = objectAngularAccelerationW;
                injectRequestMessage.ObjectFragment.ExtensionDialect             = objectExtensionDialect;
                injectRequestMessage.ObjectFragment.ExtensionDialectMajorVersion = objectExtensionDialectMajorVersion;
                injectRequestMessage.ObjectFragment.ExtensionDialectMinorVersion = objectExtensionDialectMinorVersion;
                injectRequestMessage.ObjectFragment.SetExtensionData(objectExtensionData);
                view.InjectObject(injectRequestMessage);

                Thread.Sleep(20);
                view.Process();
                Thread.Sleep(20);
                view.Process();
                Thread.Sleep(20);
                view.Process();
                Thread.Sleep(20);
                view.Process();
                Thread.Sleep(20);
                view.Process();
                Thread.Sleep(20);
                view.Process();
                Thread.Sleep(20);
                view.Process();

                CloudObject cloudObject = view.CloudCache.GetObject(objectId);

                ModifyRequestMessage modifyRequestMessage = new ModifyRequestMessage();
                cloudObject.ToObjectFragment(modifyRequestMessage.ObjectFragment);
                modifyRequestMessage.ObjectFragment.Location.X = modifiedObjectLocationX;
                modifyRequestMessage.ObjectFragment.Location.Y = modifiedObjectLocationY;
                modifyRequestMessage.ObjectFragment.Location.Z = modifiedObjectLocationZ;
                view.ModifyObject(modifyRequestMessage);

                Thread.Sleep(100);
                view.Process();

                ExamineRequestMessage examineRequestMessage = new ExamineRequestMessage();
                examineRequestMessage.ObjectIndex = cloudObject.RemoteObjectIndex;
                view.ExamineObject(examineRequestMessage);

                Thread.Sleep(100);
                view.Process();

                InteractRequestMessage interactRequesMessage = new InteractRequestMessage();
                interactRequesMessage.InteractionFragment.SourceParticipantId          = view.ParticipantId;
                interactRequesMessage.InteractionFragment.SourceObjectId               = Guid.Empty;
                interactRequesMessage.InteractionFragment.TargetParticipantId          = Guid.Empty;
                interactRequesMessage.InteractionFragment.TargetObjectId               = objectId;
                interactRequesMessage.InteractionFragment.ExtensionDialect             = objectExtensionDialect;
                interactRequesMessage.InteractionFragment.ExtensionDialectMajorVersion = objectExtensionDialectMajorVersion;
                interactRequesMessage.InteractionFragment.ExtensionDialectMinorVersion = objectExtensionDialectMinorVersion;
                interactRequesMessage.InteractionFragment.SetExtensionData(objectExtensionData);
                view.InteractWithObject(interactRequesMessage);

                Thread.Sleep(100);
                view.Process();

                EjectRequestMessage ejectRequestMessage = new EjectRequestMessage();
                ejectRequestMessage.ObjectId = objectId;
                view.EjectObject(ejectRequestMessage);

                Thread.Sleep(100);
                view.Process();
            }
            finally
            {
                if (view != null)
                {
                    view.Disconnect();

                    while (view.Client.IsTransmitterAlive)
                    {
                        Thread.Sleep(100);
                        view.Process();
                    }
                }
            }
        }
Esempio n. 6
0
        public void MovementEvent()
        {
            CloudService serviceAlpha = new CloudService(serviceAlphaAssetCacheUrl, serviceAlphaAddress, serviceAlphaHubPort, serviceAlphaServerPort, serviceAlphaProgram, serviceAlphaProgramMajorVersion, serviceAlphaProgramMinorVersion);
            CloudBubble  bubbleOne    = new CloudBubble(bubbleOneId, bubbleOneName, bubbleOneRange, bubbleOnePerceptionRange);

            serviceAlpha.AddBubble(bubbleOne);
            bubbleOne.AddAllowedRemoteHubAddress(serviceBetaAddress);

            serviceAlpha.AddBubbleLink(bubbleOneId, bubbleTwoId, serviceBetaAddress, serviceBetaHubPort, bubbleOneTwoDeltaX, bubbleOneTwoDeltaY, bubbleOneTwoDeltaZ, true, true);

            CloudService serviceBeta = new CloudService(serviceBetaAssetCacheUrl, serviceBetaAddress, serviceBetaHubPort, serviceBetaServerPort, serviceBetaProgram, serviceBetaProgramMajorVersion, serviceBetaProgramMinorVersion);
            CloudBubble  bubbleTwo   = new CloudBubble(bubbleTwoId, bubbleTwoName, bubbleTwoRange, bubbleTwoPerceptionRange);

            bubbleTwo.AddAllowedRemoteHubAddress(serviceAlphaAddress);
            serviceBeta.AddBubble(bubbleTwo);

            CloudBubble bubbleThree = new CloudBubble(bubbleThreeId, bubbleThreeName, bubbleThreeRange, bubbleThreePerceptionRange);

            bubbleThree.AddAllowedRemoteHubAddress(serviceAlphaAddress);
            bubbleThree.AddAllowedRemoteHubAddress(serviceBetaAddress);
            serviceBeta.AddBubble(bubbleThree);

            serviceBeta.AddBubbleLink(bubbleTwoId, bubbleThreeId, serviceBetaAddress, serviceBetaHubPort, bubbleTwoThreeDeltaX, bubbleTwoThreeDeltaY, bubbleTwoThreeDeltaZ, true, true);

            serviceAlpha.Startup(false);
            serviceBeta.Startup(false);

            CloudView viewOne = new CloudView(1000, clientProgramName, clientProgramMajorVersion, clientProgramMinorVersion);

            viewOne.Connect(serviceAlphaAddress, serviceAlphaServerPort, bubbleOneId, "", "", participantIdentityProviderUrl, participantNameOne, participantPassphraseOne, objectId, false);

            CloudView viewTwo = new CloudView(1000, clientProgramName, clientProgramMajorVersion, clientProgramMinorVersion);

            viewTwo.Connect(serviceBetaAddress, serviceBetaServerPort, bubbleThreeId, "", "", participantIdentityProviderUrl, participantNameTwo, participantPassphraseTwo, objectId, false);

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            Assert.IsTrue(viewOne.IsConnected);
            Assert.IsTrue(viewTwo.IsConnected);

            InjectRequestMessage injectRequestMessage = new InjectRequestMessage();

            injectRequestMessage.ObjectFragment.ObjectId                     = objectId;
            injectRequestMessage.ObjectFragment.ObjectIndex                  = objectIndex;
            injectRequestMessage.ObjectFragment.ObjectName                   = objectName;
            injectRequestMessage.ObjectFragment.TypeId                       = objectTypeId;
            injectRequestMessage.ObjectFragment.TypeName                     = objectTypeName;
            injectRequestMessage.ObjectFragment.OwnerId                      = viewOne.ParticipantId;
            injectRequestMessage.ObjectFragment.ParentObjectId               = objectParentObjectId;
            injectRequestMessage.ObjectFragment.Mass                         = objectMass;
            injectRequestMessage.ObjectFragment.BoundingSphereRadius         = objectBoundingSphereRadius;
            injectRequestMessage.ObjectFragment.Location.X                   = objectLocationX;
            injectRequestMessage.ObjectFragment.Location.Y                   = objectLocationY;
            injectRequestMessage.ObjectFragment.Location.Z                   = objectLocationZ;
            injectRequestMessage.ObjectFragment.Velocity.X                   = objectVelocityX;
            injectRequestMessage.ObjectFragment.Velocity.Y                   = objectVelocityY;
            injectRequestMessage.ObjectFragment.Velocity.Z                   = objectVelocityZ;
            injectRequestMessage.ObjectFragment.Acceleration.X               = objectAccelerationX;
            injectRequestMessage.ObjectFragment.Acceleration.Y               = objectAccelerationY;
            injectRequestMessage.ObjectFragment.Acceleration.Z               = objectAccelerationZ;
            injectRequestMessage.ObjectFragment.Orientation.X                = objectOrientationX;
            injectRequestMessage.ObjectFragment.Orientation.Y                = objectOrientationY;
            injectRequestMessage.ObjectFragment.Orientation.Z                = objectOrientationZ;
            injectRequestMessage.ObjectFragment.Orientation.W                = objectOrientationW;
            injectRequestMessage.ObjectFragment.AngularVelocity.X            = objectAngularVelocityX;
            injectRequestMessage.ObjectFragment.AngularVelocity.Y            = objectAngularVelocityY;
            injectRequestMessage.ObjectFragment.AngularVelocity.Z            = objectAngularVelocityZ;
            injectRequestMessage.ObjectFragment.AngularVelocity.W            = objectAngularVelocityW;
            injectRequestMessage.ObjectFragment.AngularAcceleration.X        = objectAngularAccelerationX;
            injectRequestMessage.ObjectFragment.AngularAcceleration.Y        = objectAngularAccelerationY;
            injectRequestMessage.ObjectFragment.AngularAcceleration.Z        = objectAngularAccelerationZ;
            injectRequestMessage.ObjectFragment.AngularAcceleration.W        = objectAngularAccelerationW;
            injectRequestMessage.ObjectFragment.ExtensionDialect             = objectExtensionDialect;
            injectRequestMessage.ObjectFragment.ExtensionDialectMajorVersion = objectExtensionDialectMajorVersion;
            injectRequestMessage.ObjectFragment.ExtensionDialectMinorVersion = objectExtensionDialectMinorVersion;
            injectRequestMessage.ObjectFragment.SetExtensionData(objectExtensionData);
            viewOne.InjectObject(injectRequestMessage);

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();


            CloudObject bubbleOneCloudObject = bubbleOne.CloudCache.GetObject(objectId);

            Assert.IsNotNull(bubbleOneCloudObject);

            CloudObject bubbleTwoCloudObject = bubbleTwo.CloudCache.GetObject(objectId);

            Assert.IsNotNull(bubbleTwoCloudObject);

            CloudObject bubbleThreeCloudObject = bubbleThree.CloudCache.GetObject(objectId);

            Assert.IsNotNull(bubbleThreeCloudObject);

            CloudObject viewOneCloudObject = viewOne.CloudCache.GetObject(objectId);

            Assert.IsNotNull(viewOneCloudObject);

            CloudObject viewTwoCloudObject = viewTwo.CloudCache.GetObject(objectId);

            Assert.IsNotNull(viewTwoCloudObject);

            MovementEventMessage movement = new MovementEventMessage();

            movement.ObjectIndex   = viewOneCloudObject.LocalObjectIndex;
            movement.Location.X    = modifiedObjectLocationX;
            movement.Location.Y    = modifiedObjectLocationY;
            movement.Location.Z    = modifiedObjectLocationZ;
            movement.Orientation.X = objectOrientationX;
            movement.Orientation.Y = objectOrientationY;
            movement.Orientation.Z = objectOrientationZ;
            movement.Orientation.W = objectOrientationW;

            viewOne.MoveObject(movement);

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            Assert.AreEqual(modifiedObjectLocationX - bubbleOneTwoDeltaX - bubbleTwoThreeDeltaX, bubbleThreeCloudObject.Location.X);
            Assert.AreEqual(modifiedObjectLocationY - bubbleOneTwoDeltaY - bubbleTwoThreeDeltaY, bubbleThreeCloudObject.Location.Y);
            Assert.AreEqual(modifiedObjectLocationZ - bubbleOneTwoDeltaZ - bubbleTwoThreeDeltaZ, bubbleThreeCloudObject.Location.Z);
            Assert.AreEqual(objectOrientationX, bubbleThreeCloudObject.Orientation.X);
            Assert.AreEqual(objectOrientationY, bubbleThreeCloudObject.Orientation.Y);
            Assert.AreEqual(objectOrientationZ, bubbleThreeCloudObject.Orientation.Z);
            Assert.AreEqual(objectOrientationW, bubbleThreeCloudObject.Orientation.W);

            EjectRequestMessage ejectRequestMessage = new EjectRequestMessage();

            ejectRequestMessage.ObjectId = objectId;
            viewOne.EjectObject(ejectRequestMessage);

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            Assert.IsNull(bubbleOne.CloudCache.GetObject(objectId));
            Assert.IsNull(bubbleTwo.CloudCache.GetObject(objectId));
            Assert.IsNull(bubbleThree.CloudCache.GetObject(objectId));
            Assert.IsNull(viewOne.CloudCache.GetObject(objectId));
            Assert.IsNull(viewTwo.CloudCache.GetObject(objectId));

            viewOne.Disconnect();
            viewTwo.Disconnect();

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            serviceAlpha.Shutdown();
            serviceBeta.Shutdown();
        }
Esempio n. 7
0
        public void ActionEvent()
        {
            CloudService serviceAlpha = new CloudService(serviceAlphaAssetCacheUrl, serviceAlphaAddress, serviceAlphaHubPort, serviceAlphaServerPort, serviceAlphaProgram, serviceAlphaProgramMajorVersion, serviceAlphaProgramMinorVersion);
            CloudBubble  bubbleOne    = new CloudBubble(bubbleOneId, bubbleOneName, bubbleOneRange, bubbleOnePerceptionRange);

            serviceAlpha.AddBubble(bubbleOne);
            bubbleOne.AddAllowedRemoteHubAddress(serviceBetaAddress);

            serviceAlpha.AddBubbleLink(bubbleOneId, bubbleTwoId, serviceBetaAddress, serviceBetaHubPort, bubbleOneTwoDeltaX, bubbleOneTwoDeltaY, bubbleOneTwoDeltaZ, true, true);

            CloudService serviceBeta = new CloudService(serviceBetaAssetCacheUrl, serviceBetaAddress, serviceBetaHubPort, serviceBetaServerPort, serviceBetaProgram, serviceBetaProgramMajorVersion, serviceBetaProgramMinorVersion);
            CloudBubble  bubbleTwo   = new CloudBubble(bubbleTwoId, bubbleTwoName, bubbleTwoRange, bubbleTwoPerceptionRange);

            bubbleTwo.AddAllowedRemoteHubAddress(serviceAlphaAddress);
            serviceBeta.AddBubble(bubbleTwo);

            CloudBubble bubbleThree = new CloudBubble(bubbleThreeId, bubbleThreeName, bubbleThreeRange, bubbleThreePerceptionRange);

            bubbleThree.AddAllowedRemoteHubAddress(serviceAlphaAddress);
            bubbleThree.AddAllowedRemoteHubAddress(serviceBetaAddress);
            serviceBeta.AddBubble(bubbleThree);

            serviceBeta.AddBubbleLink(bubbleTwoId, bubbleThreeId, serviceBetaAddress, serviceBetaHubPort, bubbleTwoThreeDeltaX, bubbleTwoThreeDeltaY, bubbleTwoThreeDeltaZ, true, true);

            serviceAlpha.Startup(false);
            serviceBeta.Startup(false);

            CloudView viewOne = new CloudView(1000, clientProgramName, clientProgramMajorVersion, clientProgramMinorVersion);

            viewOne.Connect(serviceAlphaAddress, serviceAlphaServerPort, bubbleOneId, "", "", participantIdentityProviderUrl, participantNameOne, participantPassphraseOne, objectId, false);

            CloudView viewTwo = new CloudView(1000, clientProgramName, clientProgramMajorVersion, clientProgramMinorVersion);

            viewTwo.Connect(serviceBetaAddress, serviceBetaServerPort, bubbleThreeId, "", "", participantIdentityProviderUrl, participantNameTwo, participantPassphraseTwo, objectId, false);

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            Assert.IsTrue(viewOne.IsConnected);
            Assert.IsTrue(viewTwo.IsConnected);

            InjectRequestMessage injectRequestMessage = new InjectRequestMessage();

            injectRequestMessage.ObjectFragment.ObjectId                     = objectId;
            injectRequestMessage.ObjectFragment.ObjectIndex                  = objectIndex;
            injectRequestMessage.ObjectFragment.ObjectName                   = objectName;
            injectRequestMessage.ObjectFragment.TypeId                       = objectTypeId;
            injectRequestMessage.ObjectFragment.TypeName                     = objectTypeName;
            injectRequestMessage.ObjectFragment.OwnerId                      = viewOne.ParticipantId;
            injectRequestMessage.ObjectFragment.ParentObjectId               = objectParentObjectId;
            injectRequestMessage.ObjectFragment.Mass                         = objectMass;
            injectRequestMessage.ObjectFragment.BoundingSphereRadius         = objectBoundingSphereRadius;
            injectRequestMessage.ObjectFragment.Location.X                   = objectLocationX;
            injectRequestMessage.ObjectFragment.Location.Y                   = objectLocationY;
            injectRequestMessage.ObjectFragment.Location.Z                   = objectLocationZ;
            injectRequestMessage.ObjectFragment.Velocity.X                   = objectVelocityX;
            injectRequestMessage.ObjectFragment.Velocity.Y                   = objectVelocityY;
            injectRequestMessage.ObjectFragment.Velocity.Z                   = objectVelocityZ;
            injectRequestMessage.ObjectFragment.Acceleration.X               = objectAccelerationX;
            injectRequestMessage.ObjectFragment.Acceleration.Y               = objectAccelerationY;
            injectRequestMessage.ObjectFragment.Acceleration.Z               = objectAccelerationZ;
            injectRequestMessage.ObjectFragment.Orientation.X                = objectOrientationX;
            injectRequestMessage.ObjectFragment.Orientation.Y                = objectOrientationY;
            injectRequestMessage.ObjectFragment.Orientation.Z                = objectOrientationZ;
            injectRequestMessage.ObjectFragment.Orientation.W                = objectOrientationW;
            injectRequestMessage.ObjectFragment.AngularVelocity.X            = objectAngularVelocityX;
            injectRequestMessage.ObjectFragment.AngularVelocity.Y            = objectAngularVelocityY;
            injectRequestMessage.ObjectFragment.AngularVelocity.Z            = objectAngularVelocityZ;
            injectRequestMessage.ObjectFragment.AngularVelocity.W            = objectAngularVelocityW;
            injectRequestMessage.ObjectFragment.AngularAcceleration.X        = objectAngularAccelerationX;
            injectRequestMessage.ObjectFragment.AngularAcceleration.Y        = objectAngularAccelerationY;
            injectRequestMessage.ObjectFragment.AngularAcceleration.Z        = objectAngularAccelerationZ;
            injectRequestMessage.ObjectFragment.AngularAcceleration.W        = objectAngularAccelerationW;
            injectRequestMessage.ObjectFragment.ExtensionDialect             = objectExtensionDialect;
            injectRequestMessage.ObjectFragment.ExtensionDialectMajorVersion = objectExtensionDialectMajorVersion;
            injectRequestMessage.ObjectFragment.ExtensionDialectMinorVersion = objectExtensionDialectMinorVersion;
            injectRequestMessage.ObjectFragment.SetExtensionData(objectExtensionData);
            viewOne.InjectObject(injectRequestMessage);

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();


            CloudObject bubbleOneCloudObject = bubbleOne.CloudCache.GetObject(objectId);

            Assert.IsNotNull(bubbleOneCloudObject);

            CloudObject bubbleTwoCloudObject = bubbleTwo.CloudCache.GetObject(objectId);

            Assert.IsNotNull(bubbleTwoCloudObject);

            CloudObject bubbleThreeCloudObject = bubbleThree.CloudCache.GetObject(objectId);

            Assert.IsNotNull(bubbleThreeCloudObject);

            CloudObject viewOneCloudObject = viewOne.CloudCache.GetObject(objectId);

            Assert.IsNotNull(viewOneCloudObject);

            CloudObject viewTwoCloudObject = viewTwo.CloudCache.GetObject(objectId);

            Assert.IsNotNull(viewTwoCloudObject);

            ActionEventMessage originalAction = new ActionEventMessage();

            originalAction.ActionFragment.ActionName                   = actionName;
            originalAction.ActionFragment.ObservationRadius            = actionObservationRadius;
            originalAction.ActionFragment.SourceObjectId               = objectId;
            originalAction.ActionFragment.ExtensionDialect             = actionExtensionDialect;
            originalAction.ActionFragment.ExtensionDialectMajorVersion = actionExtensionDialectMajorVersion;
            originalAction.ActionFragment.ExtensionDialectMinorVersion = actionExtensionDialectMinorVersion;
            originalAction.ActionFragment.SetExtensionData(actionExtensionData);

            viewOne.ExecuteAction(originalAction);

            ActionEventMessage receivedAction = null;

            viewTwo.ServerAction += delegate(ActionEventMessage actionEvent)
            {
                receivedAction = actionEvent;
                Assert.AreEqual(actionName, receivedAction.ActionFragment.ActionName);
                Assert.AreEqual(objectId, receivedAction.ActionFragment.SourceObjectId);
                Assert.AreEqual(actionObservationRadius, receivedAction.ActionFragment.ObservationRadius);
                Assert.AreEqual(actionExtensionDialect, receivedAction.ActionFragment.ExtensionDialect);
                Assert.AreEqual(actionExtensionDialectMajorVersion, receivedAction.ActionFragment.ExtensionDialectMajorVersion);
                Assert.AreEqual(actionExtensionDialectMinorVersion, receivedAction.ActionFragment.ExtensionDialectMinorVersion);
                Assert.AreEqual(ASCIIEncoding.ASCII.GetString(actionExtensionData),
                                ASCIIEncoding.ASCII.GetString(receivedAction.ActionFragment.GetExtensionData()));
            };

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            Assert.IsNotNull(receivedAction);

            EjectRequestMessage ejectRequestMessage = new EjectRequestMessage();

            ejectRequestMessage.ObjectId = objectId;
            viewOne.EjectObject(ejectRequestMessage);

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            Assert.IsNull(bubbleOne.CloudCache.GetObject(objectId));
            Assert.IsNull(bubbleTwo.CloudCache.GetObject(objectId));
            Assert.IsNull(bubbleThree.CloudCache.GetObject(objectId));
            Assert.IsNull(viewOne.CloudCache.GetObject(objectId));
            Assert.IsNull(viewTwo.CloudCache.GetObject(objectId));

            viewOne.Disconnect();
            viewTwo.Disconnect();

            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();
            Thread.Sleep(10);
            serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process();

            serviceAlpha.Shutdown();
            serviceBeta.Shutdown();
        }