public void AttachCamera()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);

                Operations.SpawnItem(client, "MyItem", byte.MaxValue, new[] { 10f, 10f }, null, true);
                Func<OperationResponse, bool> checkAction =
                    e => (string)e[(byte)ParameterCode.ItemId] == "MyItem" && (byte)e[(byte)ParameterCode.ItemType] == byte.MaxValue;
                client.BeginReceiveResponse(0);

                OperationResponse data;
                Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
                if (data.ReturnCode != (int)ReturnCode.Ok)
                {
                    Assert.AreEqual(ReturnCode.ItemAlreadyExists, (ReturnCode)data.ReturnCode);
                    Operations.Move(client, "MyItem", byte.MaxValue, new[] { 10f, 10f });
                }
                else
                {
                    Assert.IsTrue(checkAction(data), "check action failed");
                }

                Operations.AttachCamera(client, "MyItem", byte.MaxValue);
                client.BeginReceiveResponse(0);

                Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
                Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok);
                Assert.IsTrue(checkAction(data), "check action failed");
            }
        }
 public void Connect()
 {
     using (var client = new Client("Test"))
     {
         Assert.IsTrue(client.Connect());
         Thread.Sleep(1000);
         Assert.IsTrue(client.Disconnect());
     }
 }
Esempio n. 3
0
        public static void Move(Client client, string itemId, Vector position)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.Position, position } };
            if (itemId != null)
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            client.SendOperation((byte)OperationCode.Move, data, true);
        }
Esempio n. 4
0
 public static void CreateWorld(Client client, string worldName, BoundingBox boundingBox, Vector tileDimensions)
 {
     var data = new Dictionary<byte, object>
         {
             { (byte)ParameterCode.WorldName, worldName },
             { (byte)ParameterCode.BoundingBox, boundingBox },
             { (byte)ParameterCode.TileDimensions, tileDimensions }
         };
     client.SendOperation((byte)OperationCode.CreateWorld, data, true);
 }
Esempio n. 5
0
        public static void AttachCamera(Client client, string itemId)
        {
            var data = new Dictionary<byte, object>();

            if (!string.IsNullOrEmpty(itemId))
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            client.SendOperation((byte)OperationCode.AttachInterestArea, data, true);
        }
Esempio n. 6
0
 /// <summary>
 /// The create world.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="worldName">
 /// The world name.
 /// </param>
 /// <param name="topLeftCorner">
 /// The top left corner.
 /// </param>
 /// <param name="bottomRightCorner">
 /// The bottom right corner.
 /// </param>
 /// <param name="tileDimensions">
 /// The tile dimensions.
 /// </param>
 public static void CreateWorld(Client client, string worldName, float[] topLeftCorner, float[] bottomRightCorner, float[] tileDimensions)
 {
     var data = new Dictionary<byte, object>
         {
             { (byte)ParameterCode.WorldName, worldName }, 
             { (byte)ParameterCode.TopLeftCorner, topLeftCorner }, 
             { (byte)ParameterCode.BottomRightCorner, bottomRightCorner }, 
             { (byte)ParameterCode.TileDimensions, tileDimensions }
         };
     client.SendOperation((byte)OperationCode.CreateWorld, data, true);
 }
Esempio n. 7
0
        public void Run()
        {
            MmoWorldCache.Instance.Clear();
            MmoWorld world;
            MmoWorldCache.Instance.TryCreate(
                "HeavyLoad2", (new[] { 0f, 0f }).ToVector(), (new[] { 99f, 99f }).ToVector(), (new[] { 10f, 10f }).ToVector(), out world);

            using (var client = new Client(string.Empty))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld(world, client);
            }

            Stopwatch t = Stopwatch.StartNew();

            var clients = new List<Client>();
            try
            {
                SetupClients(world, clients, t);

                Client.ResetStats();
                log.Info("ItemPositionUpdate wait completed");
                Assert.AreEqual(0, Client.Exceptions, "Exceptions occured at exit");

                t = Stopwatch.StartNew();
                MoveClients(clients);
                PrintStats(t);
                MoveClients(clients);
                PrintStats(t);
                MoveClients(clients);
                PrintStats(t);
                MoveClients(clients);
                PrintStats(t);
                MoveClients(clients);
                PrintStats(t);
                Client.ResetStats();
                log.Info("move completed");
                Assert.AreEqual(0, Client.Exceptions, "Exceptions occured at exit");

                DisconnectClients(clients);
            }
            finally
            {
                clients.ForEach(c => c.Dispose());
            }
        }
Esempio n. 8
0
        public static void EnterWorld(
            Client client, string worldName, string username, Hashtable properties, Vector position, Vector viewDistanceEnter, Vector viewDistanceExit)
        {
            var data = new Dictionary<byte, object>
                {
                    { (byte)ParameterCode.WorldName, worldName },
                    { (byte)ParameterCode.Username, username },
                    { (byte)ParameterCode.Position, position },
                    { (byte)ParameterCode.ViewDistanceEnter, viewDistanceEnter },
                    { (byte)ParameterCode.ViewDistanceExit, viewDistanceExit }
                };
            if (properties != null)
            {
                data.Add((byte)ParameterCode.Properties, properties);
            }

            client.SendOperation((byte)OperationCode.EnterWorld, data, true);
        }
Esempio n. 9
0
        public void CreateWorld()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("CreateWorld", client);

                // "Test" defined in setup
                Operations.CreateWorld(client, "CreateWorld", new BoundingBox(new Vector(0f, 0f, 0f), new Vector(10f, 10f, 0f)), new Vector(1f, 1f, 0f));

                Func<OperationResponse, bool> checkAction = d => d.OperationCode == (byte)OperationCode.CreateWorld;
                client.BeginReceiveResponse(10);

                OperationResponse data;
                Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
                Assert.AreEqual(data.ReturnCode, (int)ReturnCode.WorldAlreadyExists);
                Assert.IsTrue(checkAction(data), "check action failed");
            }
        }
Esempio n. 10
0
        public void AttachCamera()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                EnterWorld(client, "TestWorld", new Vector(1f, 1f, 0f), new Vector(1f, 1f, 0f), new Vector(2f, 2f, 0f), null);

                SpawnItem(client);

                Func<OperationResponse, bool> checkAction =
                    e => (string)e[(byte)ParameterCode.ItemId] == "MyItem";
                OperationResponse data;
                Operations.AttachCamera(client, "MyItem");
                client.BeginReceiveResponse(0);

                Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
                Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok);
                Assert.IsTrue(checkAction(data), "check action failed");
            }
        }
Esempio n. 11
0
 /// <summary>
 /// The set view distance.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="viewDistanceEnter">
 /// The view Distance Enter.
 /// </param>
 /// <param name="viewDistanceExit">
 /// The view Distance Exit.
 /// </param>
 public static void SetViewDistance(Client client, float[] viewDistanceEnter, float[] viewDistanceExit)
 {
     var data = new Dictionary<byte, object>
         {
             { (byte)ParameterCode.ViewDistanceEnter, viewDistanceEnter }, { (byte)ParameterCode.ViewDistanceExit, viewDistanceExit } 
         };
     client.SendOperation((byte)OperationCode.SetViewDistance, data, true);
 }
Esempio n. 12
0
        /// <summary>
        /// The raise generic event.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="customEventCode">
        /// The custom event code.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        /// <param name="eventReliability">
        /// The event reliability.
        /// </param>
        /// <param name="eventReceiver">
        /// The event receiver.
        /// </param>
        public static void RaiseGenericEvent(
            Client client, string itemId, byte? itemType, byte customEventCode, object eventData, Reliability eventReliability, EventReceiver eventReceiver)
        {
            var data = new Dictionary<byte, object>
                {
                    { (byte)ParameterCode.CustomEventCode, customEventCode }, 
                    { (byte)ParameterCode.EventReliability, (byte)eventReliability }, 
                    { (byte)ParameterCode.EventReceiver, (byte)eventReceiver }
                };
            if (eventData != null)
            {
                data.Add((byte)ParameterCode.EventData, eventData);
            }

            if (itemId != null)
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            if (itemType.HasValue)
            {
                data.Add((byte)ParameterCode.ItemType, itemType.Value);
            }

            client.SendOperation((byte)OperationCode.RaiseGenericEvent, data, true);
        }
Esempio n. 13
0
        /// <summary>
        /// The set properties.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="propertiesSet">
        /// The properties set.
        /// </param>
        /// <param name="propertiesUnset">
        /// The properties unset.
        /// </param>
        public static void SetProperties(Client client, string itemId, byte? itemType, Hashtable propertiesSet, ArrayList propertiesUnset)
        {
            var data = new Dictionary<byte, object>();
            if (propertiesSet != null)
            {
                data.Add((byte)ParameterCode.PropertiesSet, propertiesSet);
            }

            if (propertiesUnset != null)
            {
                data.Add((byte)ParameterCode.PropertiesUnset, propertiesUnset);
            }

            if (itemId != null)
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            if (itemType.HasValue)
            {
                data.Add((byte)ParameterCode.ItemType, itemType.Value);
            }

            client.SendOperation((byte)OperationCode.SetProperties, data, true);
        }
Esempio n. 14
0
 /// <summary>
 /// The detach camera.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 public static void DetachCamera(Client client)
 {
     client.SendOperation((byte)OperationCode.DetachInterestArea, new Dictionary<byte, object>(), true);
 }
Esempio n. 15
0
 /// <summary>
 /// The exit world.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 public static void ExitWorld(Client client)
 {
     client.SendOperation((byte)OperationCode.ExitWorld, new Dictionary<byte, object>(), true);
 }
        /////// <summary>
        /////// The receive operation response.
        /////// </summary>
        /////// <param name="client">
        /////// The client.
        /////// </param>
        /////// <param name="operationCode">
        /////// The operation code.
        /////// </param>
        /////// <returns>
        /////// the received response event
        /////// </returns>
        ////private static Hashtable ReceiveOperationResponse(Client client, OperationCode operationCode)
        ////{
        ////    Func<Hashtable, bool> checkAction = d => (byte)d.OperationCode == (byte)operationCode;
        ////    client.BeginReceiveEvent(EventCode.OperationSuccess, checkAction, 10);
        ////    Hashtable data;
        ////    Assert.IsTrue(client.EndReceiveEvent(Settings.WaitTime, out data), "Event not received");
        ////    var eventCode = (EventCode)(byte)data.Code;
        ////    Assert.IsTrue(eventCode == EventCode.OperationSuccess || eventCode == EventCode.OperationError);
        ////    Assert.AreEqual((OperationCode)(byte)data.OperationCode, operationCode);
        ////    return data;
        ////}
        /////// <summary>
        /////// The receive operation success.
        /////// </summary>
        /////// <param name="client">
        /////// The client.
        /////// </param>
        /////// <param name="operationCode">
        /////// The operation code.
        /////// </param>
        ////private static void ReceiveOperationSuccess(Client client, OperationCode operationCode)
        ////{
        ////    Hashtable data = ReceiveOperationResponse(client, operationCode);
        ////    Assert.AreEqual((EventCode)(byte)data.Code, EventCode.OperationSuccess);
        ////}
        /// <summary>
        ///   The spawn item.
        /// </summary>
        /// <param name = "client">
        ///   The client.
        /// </param>
        private static void SpawnItem(Client client)
        {
            Operations.SpawnItem(client, "MyItem", byte.MaxValue, new[] { 1f, 1f }, null, true);

            Func<OperationResponse, bool> checkAction =
                e => (string)e[(byte)ParameterCode.ItemId] == "MyItem" && (byte)e[(byte)ParameterCode.ItemType] == byte.MaxValue;
            client.BeginReceiveResponse(0);

            OperationResponse data;
            Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
            if (data.ReturnCode != (int)ReturnCode.Ok)
            {
                Assert.AreEqual(ReturnCode.ItemAlreadyExists, (ReturnCode)data.ReturnCode);
                Operations.Move(client, "MyItem", byte.MaxValue, new[] { 1f, 1f });
            }
            else
            {
                Assert.IsTrue(checkAction(data), "check action failed");
            }
        }
        public void DestroyItem()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);
                SpawnItem(client);
                Operations.DestroyItem(client, "MyItem", byte.MaxValue);

                Func<EventData, bool> checkAction =
                    d => (string)d.Parameters[(byte)ParameterCode.ItemId] == "MyItem" && (byte)d[(byte)ParameterCode.ItemType] == byte.MaxValue;
                client.BeginReceiveEvent(EventCode.ItemDestroyed, checkAction, 10);
                EventData data;
                Assert.IsTrue(client.EndReceiveEvent(Settings.WaitTime, out data), "Event not received");
                Assert.AreEqual(data.Code, (byte)EventCode.ItemDestroyed);
                Assert.IsTrue(checkAction(data), "check action failed");
            }
        }
Esempio n. 18
0
 /////// <summary>
 /////// The receive event.
 /////// </summary>
 /////// <param name="client">
 /////// The client.
 /////// </param>
 /////// <param name="eventCode">
 /////// The event code.
 /////// </param>
 /////// <param name="checkAction">
 /////// The check action.
 /////// </param>
 /////// <returns>
 /////// </returns>
 ////private static Hashtable ReceiveEvent(Client client, Code eventCode, Func<Hashtable, bool> checkAction)
 ////{
 ////    BeginReceiveEvent(client, eventCode, checkAction);
 ////    return EndReceiveEvent(client);
 ////}
 /////// <summary>
 /////// The receive event.
 /////// </summary>
 /////// <param name="client">
 /////// The client.
 /////// </param>
 /////// <param name="eventCode">
 /////// The event code.
 /////// </param>
 /////// <returns>
 /////// </returns>
 ////private static Hashtable ReceiveEvent(Client client, Code eventCode)
 ////{
 ////    return ReceiveEvent(client, eventCode, d => true);
 ////}
 /// <summary>
 ///   The thread pool enqueue.
 /// </summary>
 /// <param name = "client">
 ///   The client.
 /// </param>
 /// <param name = "action">
 ///   The action.
 /// </param>
 private static void ThreadPoolEnqueue(Client client, Action action)
 {
     ThreadPool.QueueUserWorkItem(
         o =>
             {
                 try
                 {
                     action();
                 }
                 catch (Exception e)
                 {
                     client.HandleException(e);
                 }
             });
 }
 /// <summary>
 ///   The exit world.
 /// </summary>
 /// <param name = "client">
 ///   The client.
 /// </param>
 private static void ExitWorld(Client client)
 {
     EventData data;
     Operations.ExitWorld(client);
     client.BeginReceiveEvent(EventCode.WorldExited, d => true, 0);
     Assert.IsTrue(client.EndReceiveEvent(Settings.WaitTime, out data), "Event not received");
     Assert.AreEqual(data.Code, (byte)EventCode.WorldExited);
 }
Esempio n. 20
0
        /// <summary>
        /// The spawn item.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="properties">
        /// The properties.
        /// </param>
        /// <param name="subscribe">
        /// The subscribe.
        /// </param>
        public static void SpawnItem(Client client, string itemId, byte itemType, float[] position, Hashtable properties, bool subscribe)
        {
            var data = new Dictionary<byte, object>
                {
                    { (byte)ParameterCode.Position, position }, 
                    { (byte)ParameterCode.ItemId, itemId }, 
                    { (byte)ParameterCode.ItemType, itemType }, 
                    { (byte)ParameterCode.Subscribe, subscribe }
                };
            if (properties != null)
            {
                data.Add((byte)ParameterCode.Properties, properties);
            }

            client.SendOperation((byte)OperationCode.SpawnItem, data, true);
        }
        public void ExitWorld()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                Operations.ExitWorld(client);

                client.BeginReceiveResponse(0);

                OperationResponse data;
                Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
                Assert.AreEqual(data.ReturnCode, (byte)ReturnCode.InvalidOperation);
                EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);
                ExitWorld(client);
            }
        }
        public void UnsubscribeItem()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);

                Operations.SubscribeItem(client, client.Username, (byte)ItemType.Avatar, null);
                client.BeginReceiveEvent(EventCode.ItemSubscribed, d => (string)d[(byte)ParameterCode.ItemId] == client.Username, 0);
                EventData data;
                client.EndReceiveEvent(Settings.WaitTime, out data);
                Assert.AreEqual(data.Code, (byte)EventCode.ItemSubscribed);

                Operations.UnsubscribeItem(client, client.Username, (byte)ItemType.Avatar);
                client.BeginReceiveEvent(EventCode.ItemUnsubscribed, d => (string)d[(byte)ParameterCode.ItemId] == client.Username, 0);
                client.EndReceiveEvent(Settings.WaitTime, out data);
                Assert.AreEqual(data.Code, (byte)EventCode.ItemUnsubscribed);

                // check if subscription worked
                Operations.Move(client, null, null, new[] { 1f, 2f });

                Func<EventData, bool> checkAction = d => true;
                client.BeginReceiveEvent(EventCode.ItemMoved, checkAction, 0);
                Assert.IsFalse(client.EndReceiveEvent(Settings.WaitTime, out data), "Event received");
            }
        }
 public void SpawnItem()
 {
     using (var client = new Client("Test"))
     {
         Assert.IsTrue(client.Connect());
         CreateWorld("TestWorld", client);
         EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);
         SpawnItem(client);
     }
 }
        public void SetViewDistance()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);

                Operations.SetViewDistance(client, new[] { 2f, 2f }, new[] { 3f, 3f });

                client.BeginReceiveResponse(0);
                OperationResponse data;
                Assert.IsFalse(client.EndReceiveResponse(Settings.WaitTime, out data), "Response received");
            }
        }
        public void SetProperties()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);

                Operations.SetProperties(client, null, null, new Hashtable { { "Key", "Value" } }, null);

                client.BeginReceiveResponse(0);
                EventData data;
                Assert.IsFalse(client.EndReceiveEvent(Settings.WaitTime, out data), "Response received");
            }
        }
        public void RaiseGenericEvent()
        {
            using (var client = new Client("Test"))
            {
                Assert.IsTrue(client.Connect());
                CreateWorld("TestWorld", client);
                EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null);

                ////Operations.RaiseGenericEvent(client, null, null, byte.MaxValue, null, Reliability.Reliable, EventReceiver.WorldRegion);
                Func<EventData, bool> checkAction =
                    d =>
                    (string)d[(byte)ParameterCode.ItemId] == client.Username && (byte)d[(byte)ParameterCode.ItemType] == (byte)ItemType.Avatar &&
                    (byte)d[(byte)ParameterCode.CustomEventCode] == byte.MaxValue;

                ////client.BeginReceiveEvent(EventCode.ItemGeneric, checkAction, 0);
                EventData data;

                ////Assert.IsTrue(client.EndReceiveEvent(Settings.WaitTime, out data), "Event not received - target avatar world region");
                ////Assert.AreEqual((byte)data.Code, (byte)EventCode.ItemGeneric);
                ////Assert.IsTrue(checkAction(data), "check action failed");
                Operations.RaiseGenericEvent(client, null, null, byte.MaxValue, null, Reliability.Reliable, EventReceiver.ItemOwner);
                client.BeginReceiveEvent(EventCode.ItemGeneric, checkAction, 0);
                Assert.IsTrue(client.EndReceiveEvent(Settings.WaitTime, out data), "Event not received - target avatar owner");
                Assert.AreEqual(data.Code, (byte)EventCode.ItemGeneric);
                Assert.IsTrue(checkAction(data), "check action failed");

                Operations.RaiseGenericEvent(client, null, null, byte.MaxValue, null, Reliability.Reliable, EventReceiver.ItemSubscriber);
                client.BeginReceiveEvent(EventCode.ItemGeneric, checkAction, 0);
                Assert.IsFalse(client.EndReceiveEvent(Settings.WaitTime, out data), "Event received - avator should not be subscribed");

                // subscribe avatar
                Operations.SubscribeItem(client, client.Username, (byte)ItemType.Avatar, null);
                Operations.RaiseGenericEvent(client, null, null, byte.MaxValue, null, Reliability.Reliable, EventReceiver.ItemSubscriber);
                client.BeginReceiveEvent(EventCode.ItemGeneric, checkAction, 0);
                Assert.IsTrue(client.EndReceiveEvent(Settings.WaitTime, out data), "Event not received - target avatar subscriber");
                Assert.AreEqual(data.Code, (byte)EventCode.ItemGeneric);
                Assert.IsTrue(checkAction(data), "check action failed");
            }
        }
Esempio n. 27
0
        /// <summary>
        /// The subscribe item.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="propertiesRevision">
        /// The properties revision.
        /// </param>
        public static void SubscribeItem(Client client, string itemId, byte itemType, int? propertiesRevision)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.ItemId, itemId }, { (byte)ParameterCode.ItemType, itemType } };
            if (propertiesRevision.HasValue)
            {
                data.Add((byte)ParameterCode.PropertiesRevision, propertiesRevision);
            }

            client.SendOperation((byte)OperationCode.SubscribeItem, data, true);
        }
        /// <summary>
        ///   The create world.
        /// </summary>
        /// <param name = "world">
        ///   The world.
        /// </param>
        /// <param name = "client">
        ///   The client.
        /// </param>
        private static void CreateWorld(string world, Client client)
        {
            Operations.CreateWorld(client, world, new[] { 0f, 0f }, new[] { 10f, 10f }, new[] { 1f, 1f });

            client.BeginReceiveResponse(0);

            OperationResponse data;
            Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
            Assert.IsTrue(data.ReturnCode == (int)ReturnCode.Ok || data.ReturnCode == (int)ReturnCode.WorldAlreadyExists);
        }
Esempio n. 29
0
 /// <summary>
 /// The destroy item.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="itemId">
 /// The item id.
 /// </param>
 /// <param name="itemType">
 /// The item type.
 /// </param>
 public static void DestroyItem(Client client, string itemId, byte itemType)
 {
     var data = new Dictionary<byte, object> { { (byte)ParameterCode.ItemId, itemId }, { (byte)ParameterCode.ItemType, itemType } };
     client.SendOperation((byte)OperationCode.DestroyItem, data, true);
 }
        /// <summary>
        ///   The enter world.
        /// </summary>
        /// <param name = "client">
        ///   The client.
        /// </param>
        /// <param name = "worldName">
        ///   The world name.
        /// </param>
        /// <param name = "position">
        ///   The position.
        /// </param>
        /// <param name = "viewDistanceEnter">
        ///   The view Distance Enter.
        /// </param>
        /// <param name = "viewDistanceExit">
        ///   The view Distance Exit.
        /// </param>
        /// <param name = "properties">
        ///   The properties.
        /// </param>
        private static void EnterWorld(
            Client client, string worldName, float[] position, float[] viewDistanceEnter, float[] viewDistanceExit, Hashtable properties)
        {
            Operations.EnterWorld(client, worldName, client.Username, properties, position, viewDistanceEnter, viewDistanceExit);

            client.BeginReceiveResponse(0);

            OperationResponse data;
            Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Event not received");
            Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok);
        }