Hi all ![]()
I have problem with sending custom created objects in smartfox API.
I have a class Command (it not have a parent MonoBehaviour, simple single class), and I try to send it with smartfox API
see code:
class Command
{
public int m_nX;
private int m_nY;
public Command( int nX, int nY)
{
m_nX = nX;
m_nY = nY;
}
}
SFSObject data = new SFSObject();
// put our ONE object in data
data.put("Command", new Command(123,456) );
with sending ALL OK! (i think, what’s all OK :)))
command “new Command(123,456)” created new object in HEAP, and next this object PACKed to Object, and putting in data.
but when I try to receiving it, i.e. UNPACKING I have null in result:
// function receive data
void RecieveCommands( SFSObject data )
{
Command command_ = data.get("Command") as Command;
if( command_ == null )
{
Debug.Log( "Big problem" );
return;
}
// proceed command_
Debug.Log( "Yahoooo " + command_.m_nX );
}
Maybe anyone having this problem?
How resolve this?
Thanks!