Esempio n. 1
0
        public void TestBubbleCache()
        {
            Guid       localBubbleId = Guid.NewGuid();
            Guid       objectId      = Guid.NewGuid();
            Guid       ownerId       = Guid.NewGuid();
            CloudCache m_cloudCache  = new CloudCache(localBubbleId, 1000, new TimeSpan(0, 10, 0, 0));

            CloudObject cloudObject = new CloudObject();

            cloudObject.ObjectId             = objectId;
            cloudObject.OwnerId              = ownerId;
            cloudObject.BubbleId             = localBubbleId;
            cloudObject.Location.X           = 1;
            cloudObject.Location.Y           = 2;
            cloudObject.Location.Z           = 3;
            cloudObject.BoundingSphereRadius = 10;

            m_cloudCache.PutObject(cloudObject, true);

            Assert.IsNotNull(m_cloudCache.GetObject(objectId));
            Assert.IsNotNull(m_cloudCache.GetObject(localBubbleId, cloudObject.RemoteObjectIndex));
            Assert.AreEqual(1, m_cloudCache.GetObjectIds(0, 0, 0, 1, 1, 1, new HashSet <Guid>()).Count);
            Assert.AreEqual(1, m_cloudCache.GetBubbleObjectIds(localBubbleId).Count);
            Assert.AreEqual(1, m_cloudCache.GetParticipantObjectIds(ownerId).Count);


            m_cloudCache.RemoveObject(objectId);

            Assert.IsNull(m_cloudCache.GetObject(objectId));
            Assert.IsNull(m_cloudCache.GetObject(localBubbleId, cloudObject.RemoteObjectIndex));
            Assert.AreEqual(0, m_cloudCache.GetObjectIds(0, 0, 0, 1, 1, 1, new HashSet <Guid>()).Count);
            Assert.AreEqual(0, m_cloudCache.GetBubbleObjectIds(localBubbleId).Count);
            Assert.AreEqual(0, m_cloudCache.GetParticipantObjectIds(ownerId).Count);
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the Columns property with available columns in current table
        /// </summary>
        public static void GetColumns()
        {
            Columns = new List <string>();
            var task1 = Task.Run(async() => await LogIn("Cris", "password"));

            task1.Wait();
            var res1 = task1.Result;

            CloudApp.Init(code, key);
            Debug.WriteLine("TableName: " + Table);
            ArrayList res;

            var task = Task.Run(async() => await ServerUpDown.Load());

            task.Wait();
            res = task.Result;
            if (res.Count > 0)
            {
                CloudObject j = (CloudObject)res[0];
                foreach (var item in j.Dictionary.Keys)
                {
                    Columns.Add(item);
                }
            }
        }
Esempio n. 3
0
 private void ListViewFound_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.listViewFound.SelectedIndices.Count > 0)
     {
         CloudObject cobo = this.cloudObjects[this.listViewFound.SelectedIndices[0]];
         this.propertyGridObject.SelectedObject = cobo;
         this.richTextBoxCobo.Text = cobo.Source;
     }
 }
        public new IEnumerator Disappear()
        {
            CloudObject.SetActive(false);
            foreach (var sign in _signs)
            {
                Destroy(sign);
            }

            DisappearSound.Play();

            yield return(null);
        }
Esempio n. 5
0
 public void OnObjectRemove(CloudObject cloudObject)
 {
     LogUtil.Info("DeckEngine object remove: " + cloudObject.TypeName);
     if (m_objectUpdateQueue.Contains(cloudObject.ObjectId))
     {
         m_objectUpdateQueue.Remove(cloudObject.ObjectId);
     }
     if (DeckProgram.DeckScene.ContainsObject(cloudObject.ObjectId))
     {
         DeckProgram.DeckScene.RemoveObject(cloudObject.ObjectId);
     }
 }
Esempio n. 6
0
        public void TestBubbleCacheGarbageCollection()
        {
            Guid       localBubbleId  = Guid.NewGuid();
            Guid       remoteBubbleId = Guid.NewGuid();
            Guid       localObjectId  = Guid.NewGuid();
            Guid       remoteObjectId = Guid.NewGuid();
            CloudCache m_cloudCache   = new CloudCache(localBubbleId, 1000, new TimeSpan(0, 0, 0, 0, 10));

            CloudObject localObject = new CloudObject();

            localObject.ObjectId             = localObjectId;
            localObject.BubbleId             = localBubbleId;
            localObject.Location.X           = 1;
            localObject.Location.Y           = 2;
            localObject.Location.Z           = 3;
            localObject.BoundingSphereRadius = 10;
            m_cloudCache.PutObject(localObject, true);

            CloudObject remoteObject = new CloudObject();

            remoteObject.ObjectId             = remoteObjectId;
            remoteObject.BubbleId             = remoteBubbleId;
            remoteObject.Location.X           = 1;
            remoteObject.Location.Y           = 2;
            remoteObject.Location.Z           = 3;
            remoteObject.BoundingSphereRadius = 10;
            m_cloudCache.PutObject(remoteObject, true);

            Assert.IsNotNull(m_cloudCache.GetObject(localObjectId));
            Assert.IsNotNull(m_cloudCache.GetObject(remoteObjectId));
            Assert.IsNotNull(m_cloudCache.GetObject(localBubbleId, localObject.RemoteObjectIndex));
            Assert.IsNotNull(m_cloudCache.GetObject(remoteBubbleId, remoteObject.RemoteObjectIndex));

            m_cloudCache.Process();

            Assert.IsNotNull(m_cloudCache.GetObject(localObjectId));
            Assert.IsNotNull(m_cloudCache.GetObject(remoteObjectId));
            Assert.IsNotNull(m_cloudCache.GetObject(localBubbleId, localObject.RemoteObjectIndex));
            Assert.IsNotNull(m_cloudCache.GetObject(remoteBubbleId, remoteObject.RemoteObjectIndex));

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

            Assert.IsNotNull(m_cloudCache.GetObject(localObjectId));
            Assert.IsNull(m_cloudCache.GetObject(remoteObjectId));
            Assert.IsNotNull(m_cloudCache.GetObject(localBubbleId, localObject.RemoteObjectIndex));
            Assert.IsNull(m_cloudCache.GetObject(remoteBubbleId, remoteObject.RemoteObjectIndex));
        }
Esempio n. 7
0
        protected void AddObjectButton_Click(object sender, EventArgs e)
        {
            if (ObjectTypeDropDownList.SelectedValue == null || ObjectTypeDropDownList.SelectedValue.Length == 0)
            {
                return;
            }
            if (BubbleDropDownList.SelectedValue == null || BubbleDropDownList.SelectedValue.Length == 0)
            {
                return;
            }
            ObjectType  objectType  = ObjectLogic.GetObjectType(new Guid(ObjectTypeDropDownList.SelectedValue));
            Bubble      bubble      = BubbleLogic.GetBubble(new Guid(BubbleDropDownList.SelectedValue));
            CloudObject cloudObject = ObjectLogic.AddObject(DaemonHttpContext.LoggedInParticipant, objectType, bubble);

            Response.Redirect(Request.Url.OriginalString);
        }
Esempio n. 8
0
 public static void UpdateObject(CloudObject cloudObject)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         try
         {
             entities.Attach(cloudObject);
             ObjectType  objectType  = QueryUtil.First <ObjectType>(from o in entities.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.ObjectType);
             Participant participant = QueryUtil.First <Participant>(from o in entities.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.Participant);
             cloudObject.Modified = DateTime.Now;
             entities.SaveChanges();
         }
         finally
         {
             entities.Detach(cloudObject);
         }
     }
 }
Esempio n. 9
0
 public static CloudObject AddObject(Participant participant, ObjectType objectType, Bubble bubble)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         try
         {
             entities.Attach(participant);
             entities.Attach(objectType);
             entities.Attach(bubble);
             CloudObject cloudObject = new CloudObject
             {
                 CloudObjectId = Guid.NewGuid(),
                 Participant   = participant,
                 ObjectType    = objectType,
                 Bubble        = bubble,
                 Name          = "New " + objectType.Name,
                 Radius        = objectType.Radius,
                 Mass          = objectType.Mass,
                 ModelUrl      = objectType.ModelUrl,
                 ModelScale    = objectType.ModelScale,
                 X             = 0,
                 Y             = 0,
                 Z             = 0,
                 OX            = 0,
                 OY            = 0,
                 OZ            = 0,
                 OW            = 0,
                 Created       = DateTime.Now,
                 Modified      = DateTime.Now,
                 Enabled       = false
             };
             entities.AddToCloudObject(cloudObject);
             entities.SaveChanges();
             entities.Detach(cloudObject);
             return(cloudObject);
         }
         finally
         {
             entities.Detach(participant);
             entities.Detach(objectType);
             entities.Detach(bubble);
         }
     }
 }
Esempio n. 10
0
        static public async void Save(Dictionary <String, Item> items)
        {
            CloudApp.Init(code, key);
            foreach (KeyValuePair <String, Item> pair in items)
            {
                if (pair.Value.OnServer == false)
                {
                    CloudObject obj = new CloudObject(Table);
                    obj.ID = pair.Key;
                    obj.Set("Name", pair.Value.Name);
                    obj.Set("Type", pair.Value.Type);
                    obj.Set("Quantity", pair.Value.Quantity);
                    obj.Set("User", pair.Value.User);
                    CloudObject savedObj = await obj.SaveAsync();

                    pair.Value.OnServer = true;
                }
            }
        }
Esempio n. 11
0
 public void OnObjectUpdate(CloudObject cloudObject)
 {
     if (cloudObject.HasExtension)
     {
         OmModelPrimitiveExt modelPrimitiveExt = cloudObject.GetExtension <OmModelPrimitiveExt>();
         string modelUrl = modelPrimitiveExt.ModelUrl;
         if (!DeckProgram.AssetManager.IsBlackListed(modelUrl))
         {
             if (!DeckProgram.AssetManager.IsAssetDownloaded(modelUrl) &&
                 !DeckProgram.AssetManager.IsAssetDownloading(modelUrl))
             {
                 LogUtil.Info("Loading referenced model: " + modelUrl);
                 DeckProgram.AssetManager.DownloadAsset(modelUrl);
             }
             if (DeckProgram.AssetManager.IsAssetDownloaded(modelUrl))
             {
                 if (!m_objectUpdateQueue.Contains(cloudObject.ObjectId))
                 {
                     DeckProgram.AssetManager.EnsureModelIsLoadedToRenderer(modelUrl);
                     m_objectUpdateQueue.Add(cloudObject.ObjectId);
                 }
             }
             else
             {
                 if (!m_objectsWaitingAssets.ContainsKey(modelUrl))
                 {
                     m_objectsWaitingAssets.Add(modelUrl, new HashSet <Guid>());
                 }
                 if (!m_objectsWaitingAssets[modelUrl].Contains(cloudObject.ObjectId))
                 {
                     m_objectsWaitingAssets[modelUrl].Add(cloudObject.ObjectId);
                 }
             }
         }
     }
 }
Esempio n. 12
0
        private void Progress_ProgressChanged(object sender, OperationResult e)
        {
            Console.WriteLine(String.Format("{0} {1} {2}: {3}",
                                            e.Operation.ServiceName, e.Operation.Name, e.Operation.Region.SystemName, e.ResultText()));
            if (!e.IsError())
            {
                var iter = e.Operation.CollectedObjects.GetEnumerator();
                do
                {
                    CloudObject cobo = iter.Current;
                    if (cobo == null)
                    {
                        continue;
                    }
                    swout.WriteLine("{ \"Type\" : \"" + cobo.TypeName + "\",");
                    swout.WriteLine("  \"Service\" : \"" + cobo.Service + "\",");
                    swout.WriteLine("  \"Region\" : \"" + cobo.Region + "\",");
                    swout.WriteLine("  \"Source\" : " + cobo.Source + "}");
                    swout.WriteLine(",");
                }while (iter.MoveNext());

                swout.Flush();
            }
        }
Esempio n. 13
0
        public void Process()
        {
            if (m_objectUpdateQueue.Count > 0)
            {
                foreach (Guid objectId in m_objectUpdateQueue)
                {
                    CloudObject         cloudObject       = DeckProgram.CloudView.CloudCache.GetObject(objectId);
                    OmModelPrimitiveExt modelPrimitiveExt = cloudObject.GetExtension <OmModelPrimitiveExt>();

                    Vector3    location    = new Vector3(cloudObject.Location.X, cloudObject.Location.Y, cloudObject.Location.Z);
                    Quaternion orientation = new Quaternion(cloudObject.Orientation.W, cloudObject.Orientation.X, cloudObject.Orientation.Y, cloudObject.Orientation.Z);
                    Vector3    scale       = new Vector3(cloudObject.BoundingSphereRadius * modelPrimitiveExt.Scale, cloudObject.BoundingSphereRadius * modelPrimitiveExt.Scale, cloudObject.BoundingSphereRadius * modelPrimitiveExt.Scale);

                    bool isNewAvatar = objectId == AvatarId && !DeckProgram.DeckScene.ContainsObject(objectId);

                    if (!DeckProgram.DeckScene.ContainsObject(objectId))
                    {
                        if (IsSynchronizing)
                        {
                            CurrentObjectSynchronizationCount++;
                            if (ExpectedObjectSynchronizationCount <= CurrentObjectSynchronizationCount)
                            {
                                CurrentObjectSynchronizationCount  = 0;
                                ExpectedObjectSynchronizationCount = 0;
                                Thread.Sleep(200);
                            }
                        }

                        DeckProgram.DeckScene.AddObject(new DeckObject(objectId, cloudObject.ObjectName, cloudObject.TypeName, modelPrimitiveExt.ModelUrl, modelPrimitiveExt.Scale, location, orientation, cloudObject.BoundingSphereRadius, scale));
                    }

                    DeckObject deckObject = DeckProgram.DeckScene.GetObject(cloudObject.ObjectId);

                    if (isNewAvatar)
                    {
                        Matrix orientationMatrix;
                        Common.Rotate(out orientationMatrix, ref orientation);

                        DeckProgram.DeckRudder.AvatarTargetLocation           = location;
                        DeckProgram.DeckRudder.AvatarCurrentLocation          = location;
                        DeckProgram.DeckRudder.AvatarTargetOrientationMatrix  = orientationMatrix;
                        DeckProgram.DeckRudder.AvatarCurrentOrientationMatrix = orientationMatrix;
                        DeckProgram.DeckRudder.UpdateCameraTransformation();
                        DeckProgram.DeckRudder.SynchronizeCameraCurrentLocationWithTargetLocation();
                    }

                    deckObject.ObjectName         = cloudObject.ObjectName;
                    deckObject.NetworkLocation    = location;
                    deckObject.NetworkOrientation = orientation;
                    deckObject.Radius             = cloudObject.BoundingSphereRadius;
                    deckObject.ModelScale         = modelPrimitiveExt.Scale;
                    deckObject.NetworkScale       = scale;

                    DeckProgram.DeckScene.UpdateObject(deckObject);

                    DeckProgram.DeckScene.ActivateObject(objectId);
                }
                m_objectUpdateQueue.Clear();
            }

            if (DeckProgram.DeckRudder.IsSteered && DateTime.Now.Subtract(m_lastSteeringUpdate).TotalMilliseconds > 100)
            {
                m_lastSteeringUpdate = DateTime.Now;

                if (DeckProgram.CloudView.CloudCache.GetObject(AvatarId) != null)
                {
                    ModifyRequestMessage modifyRequestMessage = new ModifyRequestMessage();
                    modifyRequestMessage.ObjectFragment.ObjectId             = AvatarId;
                    modifyRequestMessage.ObjectFragment.OwnerId              = ParticipantId;
                    modifyRequestMessage.ObjectFragment.TypeId               = Guid.Empty;
                    modifyRequestMessage.ObjectFragment.ObjectName           = ParticipantNickName;
                    modifyRequestMessage.ObjectFragment.TypeName             = "Avatar";
                    modifyRequestMessage.ObjectFragment.BoundingSphereRadius = 2f;
                    modifyRequestMessage.ObjectFragment.Mass       = 2f;
                    modifyRequestMessage.ObjectFragment.Location.X = (float)DeckProgram.DeckRudder.AvatarTargetLocation.X;
                    modifyRequestMessage.ObjectFragment.Location.Y = (float)DeckProgram.DeckRudder.AvatarTargetLocation.Y;
                    modifyRequestMessage.ObjectFragment.Location.Z = (float)DeckProgram.DeckRudder.AvatarTargetLocation.Z;
                    Matrix     rotationMatrix = DeckProgram.DeckRudder.AvatarTargetOrientationMatrix;
                    Quaternion quaternion;
                    Common.Rotate(out quaternion, ref rotationMatrix);
                    modifyRequestMessage.ObjectFragment.Orientation.X = (float)quaternion.I;
                    modifyRequestMessage.ObjectFragment.Orientation.Y = (float)quaternion.J;
                    modifyRequestMessage.ObjectFragment.Orientation.Z = (float)quaternion.K;
                    modifyRequestMessage.ObjectFragment.Orientation.W = (float)quaternion.W;

                    OmModelPrimitiveExt modelPrimitiveExt = new OmModelPrimitiveExt();
                    modelPrimitiveExt.ModelUrl = "http://assets.bubblecloud.org/Collada/Seymour/Seymour_triangulate.dae";
                    modelPrimitiveExt.Scale    = (float)0.1f;
                    modifyRequestMessage.SetExtension(modelPrimitiveExt);

                    DeckProgram.CloudView.ModifyObject(modifyRequestMessage);
                    DeckProgram.DeckRudder.IsSteered = false;
                }
            }
        }
Esempio n. 14
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();
        }
Esempio n. 15
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. 16
0
 public void Init()
 {
     instance = new CloudObject();
 }
Esempio n. 17
0
 public void Init()
 {
     instance = new 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. 19
0
 public Notification(CloudObject notificationObject)
 {
     this.NotificationObject = notificationObject;
 }
Esempio n. 20
0
        internal static object Deserialize(object data)
        {
            if (data.GetType() == typeof(ArrayList))
            {
                ArrayList newList = new ArrayList();

                for (int i = 0; i < ((ArrayList)data).Count; i++)
                {
                    newList.Add(Deserialize((((ArrayList)data)[i])));
                }

                return(newList);
            }
            else if (data.GetType().IsArray || data.GetType() == typeof(JArray))
            {
                ArrayList newList = new ArrayList(((IEnumerable)data).Cast <object>()
                                                  .Select(x => Deserialize(x))
                                                  .ToList());
                return(newList);
            }
            else if (data.GetType() == typeof(Dictionary <string, Object>) || data.GetType() == typeof(JObject))
            {
                CB.CloudObject obj = null;

                Dictionary <string, Object> tempData = null;

                if (data.GetType() == typeof(JObject))
                {
                    tempData = ((JObject)data).ToObject <Dictionary <string, object> >();
                }
                else
                {
                    tempData = (Dictionary <string, Object>)data;
                }

                if (((Dictionary <string, Object>)(tempData)).ContainsKey("_type"))
                {
                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "custom")
                    {
                        obj = new CloudObject(((Dictionary <string, Object>)(tempData))["_tableName"].ToString());
                    }

                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "user")
                    {
                        obj = new CloudUser();
                    }

                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "role")
                    {
                        obj = new CloudRole(((Dictionary <string, Object>)(tempData))["name"].ToString());
                    }

                    if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "point")
                    {
                        //return geopoint dictionary.
                        CloudGeoPoint point = new CloudGeoPoint(Decimal.Parse(((Dictionary <string, Object>)(tempData))["longitude"].ToString()), Decimal.Parse(((Dictionary <string, Object>)(tempData))["latitude"].ToString()));
                        return(point);
                    }

                    foreach (var param in ((Dictionary <string, Object>)(tempData)))
                    {
                        if (param.Value == null)
                        {
                            obj.dictionary[param.Key] = null;
                        }
                        else if (param.Key == "ACL")
                        {
                            var acl = new CB.ACL();
                            obj.dictionary[param.Key] = acl;
                        }
                        else if (param.Key == "expires")
                        {
                            obj.dictionary["expires"] = ((Dictionary <string, Object>)(tempData))["expires"];
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "custom")
                        {
                            CB.CloudObject cbObj = new CB.CloudObject(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_tableName"].ToString());
                            cbObj = (CloudObject)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >());
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "user")
                        {
                            CB.CloudUser cbObj = new CB.CloudUser();
                            cbObj = (CloudUser)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >());
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "custom")
                        {
                            CB.CloudRole cbObj = new CB.CloudRole(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["name"].ToString());
                            cbObj = (CloudRole)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >());
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "point")
                        {
                            CB.CloudGeoPoint cbObj = new CB.CloudGeoPoint(Decimal.Parse(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["longitude"].ToString()), Decimal.Parse(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["latitude"].ToString()));
                            cbObj = (CloudGeoPoint)(Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()));
                            obj.dictionary[param.Key] = cbObj;
                        }
                        else if (param.Value.GetType() == typeof(ArrayList))
                        {
                            obj.dictionary[param.Key] = Deserialize(param.Value);
                        }
                        else if (param.Value.GetType().IsArray)
                        {
                            obj.dictionary[param.Key] = Deserialize(param.Value);
                        }
                        else if (param.Value.GetType() == typeof(JArray))
                        {
                            obj.dictionary[param.Key] = Deserialize(param.Value);
                        }
                        else
                        {
                            obj.dictionary[param.Key] = param.Value;
                        }
                    }

                    return(obj);
                }
                else
                {
                    return(tempData);
                }
            }

            return(data);
        }
Esempio n. 21
0
 public SilentNotification(CloudObject notificationObject) : base(notificationObject)
 {
 }