Data types in "sendOperation"

edited May 2012 in Flash (deprecated)
We are using Photon in our cross-platform iOS + Flash + Androind game project. For optimization purposes we decided to use "short" and "char" numeric data types on iOS and server-side. But there is no way we can control numeric data types in AS3:
var data: Array = [
233,    // would be nice to cast this into char
500     // would be nice to cast this into short, etc
sendOperation(ProtocolConstants.OP_PLAYER_UPDATE, data);

So, all numeric data in the "data" Array is converted into "int" by Photon, and we get "type coercion" errors on our server, since it expects "short" or "char". Is there any way to get over this issue? Accepting ByteArray as input data source in flash sdk would, probably, solve this issuse:
var data: ByteArray = new ByteArray();
data.writeShort(500)    // we control the type of numbers- nice!
sendOperation(ProtocolConstants.OP_PLAYER_UPDATE, data);


  • This is unluckily a thing you can't do anything about without extra work on your end.

    1. Either use common datatypes available in all technologies you use (means basically: what flash offers)
    2. Expand your server to offer operations explicitely for flash and then convert the datatype for the less limited platforms.

    The data size optimization will still be lost but after all flash also always runs on TCP too so its the unliked little brother whenever you do cross technology development that holds back the others or requires extra work on your end to not punish non-flashers
  • dreamora wrote:
    This is unluckily a thing you can't do anything about without extra work on your end.

    Thank you for the quick response! I think we'll stick with integers for now.
  • Actionscript only has int and Number, but no such things like different integer types for different sizes.
    So dreamora is right: you will either have to stick to int or offer an optimized operation with types like char and short for other clients and fall back to an unoptimized version of it for flash and then depending on the keys in the op and the opCode let the server convert it into the (un-)optimized version of the operation before sending it further.
    The second approach will of course be some extra work and can't be used with the cloud, but only with self hosted servers, so I would only choose it, if your other clients would really significantly profit from this optimization.

    He is also right about Flash clients being bound to TCP, so everything will always be sent reliable between the server and the Flash clients, but other clients will still profit, if you use udp and send stuff, for which it makes sense, unreliable for them.