Skip to content

Commit

Permalink
fix api inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
dpomier committed Jul 10, 2018
1 parent 17cbc58 commit 58ae5c1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
37 changes: 31 additions & 6 deletions com/smartfoxserver/v2/entities/data/SFSDataWrapper.hx
Expand Up @@ -6,16 +6,41 @@ package com.smartfoxserver.v2.entities.data;
* A wrapper object used by SFSObject and SFSArray to encapsulate data and relative types.
*/

#if !html5

class SFSDataWrapper
{
public var type(default,null):Int;
public var data(default,null):Dynamic;
#if html5
public var value(default,null):Dynamic;
#end
public var type(default, null):Int;
public var data(default, null):Dynamic;

public function new(type:Int, data:Dynamic)
{
this.type = type;
this.data = data;
}
}
}

#else

abstract SFSDataWrapper (SFSDataWrapperExtern)
{
public var type (get,never):Int;
public var data (get,never):Dynamic;

public inline function new (type:Int, data:Dynamic)
{
this = cast { type: type, value:data };
}

private inline function get_data ():Dynamic return this.value;
private inline function get_type ():Dynamic return this.type;
}

@:native('SFS2X.SFSDataWrapper')
private extern class SFSDataWrapperExtern
{
public var type(default,null):Int;
public var value(default, null):Dynamic;
}

#end
Expand Up @@ -80,11 +80,7 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
// Store the key
buffer = encodeSFSObjectKey(buffer, key);
// Convert 2 binary
#if html5
buffer = encodeObject(buffer, wrapper.type, wrapper.value);
#else
buffer = encodeObject(buffer, wrapper.type, wrapper.data);
#end
}

return buffer;
Expand Down

0 comments on commit 58ae5c1

Please sign in to comment.