Example #1
0
        public static string Get(Request packet)
        {
            long id;
            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Group));
                return "[0,\"Could not find ID\"]";
            }

            var obj = GetObject(id);
            if (obj.IsNew)
                return "[1,'[]']";
            lock (obj.Locker)
            {
                return String.Format("[1,'[\"{0}\",\"{1}\",{2},{3},{4}]']",
                    obj._groupName,
                    obj._leaderName,
                    obj._level,
                    obj._mods,
                    obj._members
                    );
            }
        }
Example #2
0
        public static string Get(Request packet)
        {
            int id;
            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Storage));
                return "[0,\"Could not find ID\"]";
            }

            var obj = GetObject(id);
            if (obj.IsNew)
                return "[1,'[]']";
            lock (obj.Locker)
            {
                return String.Format("[1,'[\"{0}\",{1},{2},{3},{4},{5},{6}]']",
                    obj._class,
                    obj._position,
                    obj._damage,
                    obj._inventory,
                    obj._texture,
                    obj._owners,
                    obj._parent
                    );
            }
        }
Example #3
0
        public static string Set(Request packet)
        {
            int id;
            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Ai));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count != 3)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof(Ai));
                return "[0,\"The request was malformed\"]";
            }

            var ai = GetObject(id);
            lock (ai.Locker)
            {
                ai._expiry = packet.Expiry;
                ai._class = packet.Data.AsString(0);
                ai._home = ArmaArray.Serialize(packet.Data.AsArray(1));
                ai._work = ArmaArray.Serialize(packet.Data.AsArray(2));
                ai.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating ai: {0}", id), Logger.LogType.Info, typeof(Ai));
            return "[1,\"Success\"]";
        }
Example #4
0
        public static string Get(Request packet)
        {
            int id;
            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Plotpole));
                return "[0,\"Could not find ID\"]";
            }

            var obj = GetObject(id);
            if (obj.IsNew)
                return "[1,'[]']";
            lock (obj.Locker)
            {
                return String.Format("[1,'[{0},{1}]']",
                    obj._names,
                    obj._pids
                    );
            }
        }
Example #5
0
        public static string Set(Request packet)
        {
            int id;
            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Building));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count != 1)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof(LockboxPin));
                return "[0,\"The request was malformed\"]";
            }

            var lockboxpin = GetObject(id);

            lock (lockboxpin.Locker)
            {
                lockboxpin._expiry = packet.Expiry;
                lockboxpin._pin = packet.Data.AsString(0);
                lockboxpin.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating LockboxPin: {0}", id), Logger.LogType.Info, typeof(LockboxPin));

            return "[1,\"Success\"]";
        }
Example #6
0
        public static string Set(Request packet)
        {
            long id;
            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof (Bank));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count != 1)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof (Bank));
                return "[0,\"The request was malformed\"]";
            }
            var bank = GetObject(id);
            lock (bank.Locker)
            {
                bank._expiry = packet.Expiry;
                bank._amount = packet.Data.AsInt(0);
                bank.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating Bank: {0}", id), Logger.LogType.Debug, typeof (Bank));
            return "[1,\"Success\"]";
        }
Example #7
0
        public static string Set(Request packet)
        {
            long id;
            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof (PlayerData));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count != 1)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof (PlayerData));
                return "[0,\"The request was malformed\"]";
            }

            var playerdata = GetObject(id);
            lock (playerdata.Locker)
            {
                playerdata._expiry = packet.Expiry;
                playerdata._name = packet.Data.AsString(0);
                playerdata.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating PlayerData: {0}", id), Logger.LogType.Info, typeof (PlayerData));

            return "[1,\"Success\"]";
        }
Example #8
0
        public static string Set(Request packet)
        {
            int id;
            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Plotpole));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count != 2)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof(Plotpole));
                return "[0,\"The request was malformed\"]";
            }

            var plotpole = GetObject(id);

            lock (plotpole.Locker)
            {
                plotpole._expiry = packet.Expiry;
                plotpole._names = ArmaArray.Serialize(packet.Data.AsArray(0));
                plotpole._pids = ArmaArray.Serialize(packet.Data.AsArray(1));
                plotpole.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating Plotpole: {0}", id), Logger.LogType.Info, typeof(Plotpole));

            return "[1,\"Success\"]";
        }
Example #9
0
 public static string Set(Request packet)
 {
     var id = packet.InstanceId;
     lock (TypeLocker)
     {
         var store = new Store {_key = id, _expiry = packet.Expiry, _data = packet.Data.ToString()};
         store.SaveOrUpdate();
     }
     Logger.Log(String.Format("Saving store: {0}", packet.Data), Logger.LogType.Info, typeof (Store));
     return "[1,\"Success\"]";
 }
Example #10
0
 public static void Del(Request packet)
 {
     long id;
     try
     {
         id = Convert.ToInt64(packet.InstanceId);
     }
     catch (Exception ex)
     {
         Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
             Logger.LogType.Error, typeof(Group));
         return;
     }
     DeleteObject(id);
 }
Example #11
0
        public static string Set(Request packet)
        {
            if (packet.Data.Count != 2)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof (Log));
                return "[0,\"The request was malformed\"]";
            }

            var log = new Log {_type = packet.Data.AsString(0), _entry = packet.Data.AsString(1)};
            log.SaveOrUpdate();

            Logger.Log(String.Format("Adding log: {0}", log._type), Logger.LogType.Info, typeof (Log));

            return "[1,\"Success\"]";
        }
Example #12
0
 public static void Expire(Request packet)
 {
     int id;
     try
     {
         id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
     }
     catch (Exception ex)
     {
         Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
             Logger.LogType.Error, typeof(Building));
         return;
     }
     var obj = GetObject(id);
     lock (obj.Locker)
     {
         obj._expiry = packet.Expiry;
     }
     Logger.Log(String.Format("Expiry reset: {0}", id), Logger.LogType.Info, typeof(Building));
 }
Example #13
0
 public static string Get(Request packet)
 {
     long id;
     try
     {
         id = Convert.ToInt64(packet.InstanceId);
     }
     catch (Exception ex)
     {
         Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
             Logger.LogType.Error, typeof(Player));
         return "[0,\"Could not find ID\"]";
     }
     var obj = GetObject(id);
     if (obj.IsNew)
         return "[1,'[]']";
     lock (obj.Locker)
     {
         return String.Format("[1,'[{0}]']",
             obj._amount
             );
     }
 }
Example #14
0
        private string GetBit(Request packet)
        {
            if (!_tablemap.ContainsKey(packet.Table))
            {
                throw new Exception(String.Format("Unknown table: {0}", packet.Table));
            }
            var cls = _tablemap[packet.Table];

            var m = cls.GetMethod("GetBit", BindingFlags.Public | BindingFlags.Static);
            if (m != null)
            {
                return (m.Invoke(null, new object[] { packet })) as string;
            }
            throw new Exception(String.Format("The requested object does not implement GetBit"));
        }
Example #15
0
        private static string UpdatePlayerStats(long id, Request packet)
        {
            if (packet.Data.Count != 2)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof(Player));
                return "[0,\"The request was malformed\"]";
            }

            int key;
            int val;
            try
            {
                key = packet.Data.AsInt(0);
                val = packet.Data.AsInt(1);
            }
            catch
            {
                Logger.Log(String.Format("Packet error: {0}", String.Join(", ", packet)), Logger.LogType.Error,
                    typeof(Player));
                return "[0,\"The request was malformed\"]";
            }

            Logger.Log(String.Format("Updating PlayerStats: {0}", id), Logger.LogType.Info, typeof(Player));

            var player = GetObject(id);
            lock (player.Locker)
            {
                if (key == 0)
                {
                    player._dead = val == 1;
                }
                player.SaveOrUpdate();
            }
            return "[1,\"Success\"]";
        }
Example #16
0
        public static string Set(Request packet)
        {
            int id;
            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof (Storage));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count == 0)
            {
                DeleteObject(id);
                return "[1,\"Success\"]";
            }

            if (packet.Data.Count != 7)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof (Storage));
                return "[0,\"The request was malformed\"]";
            }

            var storage = GetObject(id);
            lock (storage.Locker)
            {
                storage._expiry = packet.Expiry;
                storage._class = packet.Data.AsString(0);
                storage._position = ArmaArray.Serialize(packet.Data.AsArray(1));
                storage._damage = packet.Data.AsFloat(2);
                storage._inventory = ArmaArray.Serialize(packet.Data.AsArray(3));
                storage._texture = packet.Data.AsInt(4);
                storage._owners = ArmaArray.Serialize(packet.Data.AsArray(5));
                storage._parent = packet.Data.AsInt(6);
                storage.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating Storage: {0}", id), Logger.LogType.Info, typeof (Storage));

            return "[1,\"Success\"]";
        }
Example #17
0
        public static string GetBit(Request packet)
        {
            long id;
            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Player));
                return "[0,\"Could not find ID\"]";
            }
            var obj = GetObject(id);

            if (packet.Bit != 0)
            {
                Logger.Log(String.Format("Bit {0} is not valid", packet.Bit),
                    Logger.LogType.Error, typeof(Player));
                return "[0,\"Invalid bit\"]";
            }

            lock (obj.Locker)
            {
                return String.Format("[1,\"{0}\"]",
                    (obj._dead) ? "1" : "0"
                    );
            }
        }
Example #18
0
        public static string Set(Request packet)
        {
            long id;
            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Player));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Table == "PLAYERSTATS")
            {
                return UpdatePlayerStats(id, packet);
            }

            if (packet.Data.Count != 12)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof(Player));
                return "[0,\"The request was malformed\"]";
            }

            Logger.Log(String.Format("Updating Player: {0}", id), Logger.LogType.Info, typeof(Player));

            var player = GetObject(id);
            lock (player.Locker)
            {
                player._expiry = packet.Expiry;
                player._worldspace = ArmaArray.Serialize(packet.Data.AsArray(0));
                player._medical = ArmaArray.Serialize(packet.Data.AsArray(1));
                player._appearance = ArmaArray.Serialize(packet.Data.AsArray(2));
                player._vars = ArmaArray.Serialize(packet.Data.AsArray(4));
                player._weapons = ArmaArray.Serialize(packet.Data.AsArray(5));
                player._assignedItems = ArmaArray.Serialize(packet.Data.AsArray(6));
                player._magazinesAmmo = ArmaArray.Serialize(packet.Data.AsArray(7));
                player._itemsplayer = ArmaArray.Serialize(packet.Data.AsArray(8));
                player._weaponsplayer = ArmaArray.Serialize(packet.Data.AsArray(9));
                player._group = packet.Data.AsString(10);
                player._revive = packet.Data.AsBool(11);
                player.SaveOrUpdate();
            }
            return "[1,\"Success\"]";
        }
Example #19
0
        private void Del(Request packet)
        {
            if (!_tablemap.ContainsKey(packet.Table))
            {
                throw new Exception(String.Format("Unknown table: {0}", packet.Table));
            }
            var cls = _tablemap[packet.Table];

            var m = cls.GetMethod("Del", BindingFlags.Public | BindingFlags.Static);
            if (m != null)
            {
                m.Invoke(null, new object[] {packet});
            }
            else
            {
                throw new Exception(String.Format("The requested object does not implement Del"));
            }
        }
Example #20
0
 public static string Get(Request packet)
 {
     long id;
     try
     {
         id = Convert.ToInt64(packet.InstanceId);
     }
     catch (Exception ex)
     {
         Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
             Logger.LogType.Error, typeof(Player));
         return "[0,\"Could not find ID\"]";
     }
     var obj = GetObject(id);
     if (obj.IsNew)
         return "[1,'[]']";
     lock (obj.Locker)
     {
         return String.Format("[1,'[{0},{1},{2},[],{3},{4},{5},{6},{7},{8},\"{9}\",{10}]']",
             obj._worldspace,
             obj._medical,
             obj._appearance,
             obj._vars,
             obj._weapons,
             obj._assignedItems,
             obj._magazinesAmmo,
             obj._itemsplayer,
             obj._weaponsplayer,
             obj._group,
             obj._revive
             );
     }
 }
Example #21
0
        private string _parse(string packet)
        {
            Request request;
            try
            {
                request = new Request(packet);
            }
            catch (RequestException ex)
            {
                Logger.Log(String.Format("Error parsing request: {0}", ex.Message), Logger.LogType.Error,
                    typeof(Manager));
                return "[0,\"Request is malformed\"]";
            }
            var response = "[1,\"Done\"]";
            switch (request.Command)
            {
                case Request.Commands.Set:
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            Set(request);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(String.Format("Set Error: {0} - {1}", ex.Message, packet), Logger.LogType.Error,
                                typeof(Manager));
                        }
                    });
                    response = "[1,\"Done\"]";
                    break;

                case Request.Commands.GetAsync:
                    var t = Task<string>.Factory.StartNew(() =>
                    {
                        try
                        {
                            return Get(request);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(String.Format("GetAsync Error: {0} - {1}", ex.Message, packet), Logger.LogType.Error,
                                typeof(Manager));
                            return "[0,\"Error\"]";
                        }
                    });
                    var tid = Interlocked.Increment(ref _taskPointer);
                    _tasks.Add(tid, t);
                    response = String.Format("[1,{0}]", tid);
                    break;

                case Request.Commands.GetSync:
                    try
                    {
                        response = Get(request);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(String.Format("GetSync Error: {0} - {1}", ex.Message, packet), Logger.LogType.Error,
                            typeof(Manager));
                        response = "[0,\"Error\"]";
                    }
                    break;

                case Request.Commands.GetBit:
                    try
                    {
                        response = GetBit(request);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(String.Format("GetBit Error: {0} - {1}", ex.Message, packet), Logger.LogType.Error,
                            typeof(Manager));
                        response = "[0,\"Error\"]";
                    }
                    break;

                case Request.Commands.Del:
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            Del(request);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(String.Format("Del Error: {0} - {1}", ex.Message, packet), Logger.LogType.Error,
                                typeof(Manager));
                        }
                    });
                    break;

                case Request.Commands.Expire:
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            Expire(request);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(String.Format("Expire Error: {0} - {1}", ex.Message, packet), Logger.LogType.Error,
                                typeof(Manager));
                        }
                    });
                    break;

                case Request.Commands.Response:
                    try
                    {
                        response = Response(request);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(String.Format("Response Error: {0} - {1}", ex.Message, packet), Logger.LogType.Error,
                            typeof(Manager));
                        response = "[0,\"Error\"]";
                    }
                    break;
            }
            return response;
        }
Example #22
0
        private string Response(Request packet)
        {
            Task<string> task;
            if (!_tasks.TryGetValue(packet.Tid, out task))
            {
                throw new Exception(String.Format("Could not find task with id: {0}", packet.Tid));
            }

            if (!task.IsCompleted)
            {
                return "WAIT";
            }

            var response = task.Result;
            if (response.Length < _maxOutput)
            {
                _tasks.Remove(packet.Tid);
                return response;
            }

            var parts = (int)Math.Ceiling((double)response.Length / (double)_maxOutput);
            var part = packet.Part;

            if (part >= parts)
            {
                throw new Exception(String.Format("Trying to get part that is out of bounds: {0}", String.Join(", ", packet)));
            }
            var start = _maxOutput * part;
            var length = _maxOutput;

            if ((start + length) >= response.Length)
            {
                length = response.Length - start;
                _tasks.Remove(packet.Tid);
            }

            return response.Substring(start, length);
        }
Example #23
0
        public static string Set(Request packet)
        {
            long id;
            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Group));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count != 5)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                    typeof(Group));
                return "[0,\"The request was malformed\"]";
            }

            var group = GetObject(id);
            lock (group.Locker)
            {
                group._expiry = packet.Expiry;
                group._groupName = packet.Data.AsString(0);
                group._leaderName = packet.Data.AsString(1);
                group._level = packet.Data.AsInt(2);
                group._mods = ArmaArray.Serialize(packet.Data.AsArray(3));
                group._members = ArmaArray.Serialize(packet.Data.AsArray(4));
                group.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating Group: {0}", id), Logger.LogType.Info, typeof(Group));

            return "[1,\"Success\"]";
        }
Example #24
0
        public static string Set(Request packet)
        {
            int id;
            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                    Logger.LogType.Error, typeof(Building));
                return "[0,\"Could not find ID\"]";
            }

            if (packet.Data.Count == 0)
            {
                DeleteObject(id);
                return "[1,\"Success\"]";
            }
            if (packet.Data.Count < 2)
            {
                Logger.Log(String.Format("Error parsing: {0}", packet.InstanceId), Logger.LogType.Error,
                    typeof(Building));
                return "[0,\"The request was malformed\"]";
            }
            var building = GetObject(id);
            lock (building.Locker)
            {
                building._expiry = packet.Expiry;
                building._class = packet.Data.AsString(0);
                building._position = ArmaArray.Serialize(packet.Data.AsArray(1));

                switch (packet.Data.Count)
                {
                    case 2:
                        break;

                    case 5:
                        building._storageId = packet.Data.AsInt(2);
                        building._playerId = packet.Data.AsLong(3);
                        building._texture = packet.Data.AsInt(4);
                        break;

                    case 6:
                        building._storageId = packet.Data.AsInt(2);
                        building._playerId = packet.Data.AsLong(3);
                        building._texture = packet.Data.AsInt(4);
                        building._damage = packet.Data.AsFloat(5);
                        break;

                    default:
                        Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                            typeof(Building));
                        return "[0,\"The request was malformed\"]";
                }
                building.SaveOrUpdate();
                Logger.Log(String.Format("Updating Building: {0}", id), Logger.LogType.Info, typeof(Building));
            }
            return "[1,\"Success\"]";
        }
Example #25
0
 public static string Get(Request packet)
 {
     int id;
     try
     {
         id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
     }
     catch (Exception ex)
     {
         Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
             Logger.LogType.Error, typeof(Building));
         return "[0,\"Could not find ID\"]";
     }
     var obj = GetObject(id);
     if (obj.IsNew)
         return "[1,'[]']";
     lock (obj.Locker)
     {
         return String.Format("[1,'[\"{0}\",{1},\"{2}\",\"{3}\",{4},{5}]',{6}]",
             obj._class,
             obj._position,
             obj._storageId,
             obj._playerId,
             obj._texture,
             obj._damage,
             (obj.Expiry - DateTime.Now).TotalSeconds
             );
     }
 }