Smartfox Send Data WriteUTF Exception (Unity)

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

ersindemir
Posts: 26
Joined: 30 Apr 2016, 07:23
Location: Turkey
Contact:

Smartfox Send Data WriteUTF Exception (Unity)

Postby ersindemir » 06 Feb 2017, 12:30

Sometimes I got exception with the following code;

Code: Select all

//string groupId;
//int? gameType;

SFSObject sfsObject = new SFSObject();

if (!string.IsNullOrEmpty(groupId))
       sfsObject.PutUtfString("groupId", groupId);

if (gameType.HasValue)
       sfsObject.PutInt("gameType", gameType.Value);


How can I fix it ?

Stack Trace;

Code: Select all

Object reference not set to an instance of an object
       at Sfs2X.Util.ByteArray.WriteUTF(Sfs2X.Util.ByteArray)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.BinEncode_UTF_STRING(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.EncodeObject(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.Obj2bin(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.Object2Binary(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.EncodeObject(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.Obj2bin(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.Object2Binary(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.EncodeObject(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.Obj2bin(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer.Object2Binary(Sfs2X.Protocol.Serialization.DefaultSFSDataSerializer)
       at Sfs2X.Entities.Data.SFSObject.ToBinary(Sfs2X.Entities.Data.SFSObject)
       at Sfs2X.Core.SFSIOHandler.OnDataWrite(Sfs2X.Core.SFSIOHandler)
       at Sfs2X.Core.SFSProtocolCodec.OnPacketWrite(Sfs2X.Core.SFSProtocolCodec)
       at Sfs2X.Bitswarm.BitSwarmClient.Send(Sfs2X.Bitswarm.BitSwarmClient)
       at Sfs2X.SmartFox.Send(Sfs2X.SmartFox)


Unity Version : 5.5.0
Platform : Android
Smartfox Backend : 2.12.0 (Java)
Client smartfox version : 1.6.6
User avatar
Lapo
Site Admin
Posts: 20113
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox Send Data WriteUTF Exception (Unity)

Postby Lapo » 06 Feb 2017, 16:13

Hi,
the code looks incomplete. What happens next?
I mean after those two conditions.

Is there a way in which the error can be reproduced? Does it depend on those two conditions? If so how?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
ersindemir
Posts: 26
Joined: 30 Apr 2016, 07:23
Location: Turkey
Contact:

Re: Smartfox Send Data WriteUTF Exception (Unity)

Postby ersindemir » 07 Feb 2017, 05:56

Code: Select all

//string groupId;
//int? gameType;

SFSObject sfsObject = new SFSObject();

if (!string.IsNullOrEmpty(groupId))
       sfsObject.PutUtfString("groupId", groupId);

if (gameType.HasValue)
       sfsObject.PutInt("gameType", gameType.Value);
      
smartfox.Send(new ExtensionRequest("playGame", sfsObject, null));


I found this exception Crashlytics. I can not reproduce it.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 1 guest