View Full Version : EsObject variable types
jproffer
06-29-2011, 02:58 PM
I need to store a hashmap in EsObject, since I can't create a dynamic EsObjectArray. I don't see a .set* option for anything other than basic types, e.g. byte, array, string, etc? Is there a way?
tcarr
06-29-2011, 03:08 PM
If this is information that is being sent between a client and the server, you will have to package it as an EsObject of some kind. What I normally do is make an object class for the value being stored, which includes an id or key property for the key. Then I add a toEsObject() method on this class, and either a static fromEsObject or a constructor that takes an EsObject parameter. When sending the hashmap, create an EsObject array that is the correct size, and iterate through the map storing the value.toEsObject() into the current index of the array. On the other end, you unpack it similarly.
For sharing information between two plugins in the same extension, it's EASY. Just put your hashmap into a managed object.
tcarr
06-29-2011, 03:10 PM
Further comment: usually I don't send an entire hashmap except when a game is just about to start and we need to initialize all the players. What I do is send any item in the hashmap that changes. If these update messages are coming frequently, I send them as queued plugin messages. So the server has a map, the client has a map, but only the changed objects get sent as messages.
jproffer
06-30-2011, 12:19 AM
Thanks, our game is fairly complex and we do require hashmaps. For now, I've created a custom class with the hashmap, and a .toESO() which generates an EsObject of all data plus an EsObjectArray with the hashmap values. I unfortunately can't really explain in detail as to why we need it this way, since my bosses want the game in stealth mode until we launch. =/
tcarr
06-30-2011, 01:07 AM
I fully understand about NDAs etc. And I have a tiny bit of experience with Unity which seems to want to send hash tables. I managed to avoid sending entire hash tables in my Unity examples but I didn't do anything that was really complicated either.
Powered by vBulletin® Version 4.1.6 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.