Skip to content

Commit

Permalink
Disconnect fix (barisyild) + deprecation error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiEggz committed Aug 8, 2023
1 parent 825571e commit 64af287
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
13 changes: 10 additions & 3 deletions com/smartfoxserver/v2/bitswarm/BitSwarmClient.hx
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class BitSwarmClient extends EventDispatcher
* reconnection to the server.
*/
_attemptingReconnection = true;
_firstReconnAttempt=haxe.Timer.stamp();
_firstReconnAttempt = haxe.Timer.stamp() * 1000;
_reconnCounter=1;

// Fire event and retry
Expand All @@ -503,8 +503,8 @@ class BitSwarmClient extends EventDispatcher
if(!_attemptingReconnection)
return;

var reconnectionSeconds:Int=sfs.getReconnectionSeconds()* 1000;
var now:Float=haxe.Timer.stamp();
var reconnectionSeconds:Int = sfs.getReconnectionSeconds() * 1000;
var now:Float = haxe.Timer.stamp() * 1000;
var timeLeft:Float=(_firstReconnAttempt + reconnectionSeconds)- now;

if(timeLeft>0)
Expand Down Expand Up @@ -562,6 +562,13 @@ class BitSwarmClient extends EventDispatcher

private function processIOError(error:String):Void
{
// Reconnection failure
if(_attemptingReconnection)
{
reconnect();
return;
}

trace("## SocketError:" + error);
var event:BitSwarmEvent = new BitSwarmEvent(BitSwarmEvent.IO_ERROR);
event.params = {
Expand Down
3 changes: 1 addition & 2 deletions com/smartfoxserver/v2/bitswarm/wsocket/WSClient.hx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smartfoxserver.v2.bitswarm.wsocket;
package com.smartfoxserver.v2.bitswarm.wsocket;

import openfl.events.Event;
import openfl.Lib;
Expand Down Expand Up @@ -102,4 +102,3 @@ class WSClient extends EventDispatcher
ws.close();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
if(classFullName==null)
throw new SFSCodecError("Cannot detect class name:" + sfsObj);

if(!(Std.is(asObj, SerializableSFSType)))
if(!(Std.isOfType(asObj, SerializableSFSType)))
throw new SFSCodecError("Cannot serialize object:" + asObj + ", type:" + classFullName + " -- It doesn't implement the SerializableSFSType Interface");

var fieldList:ISFSArray = SFSArray.newInstance();
Expand Down Expand Up @@ -958,13 +958,13 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
var wrapper:SFSDataWrapper=null;
var type:String = Type.getClassName(Type.getClass(value));

if(Std.is(value, Bool))
if(Std.isOfType(value, Bool))
wrapper = new SFSDataWrapper(SFSDataType.BOOL, value);

else if(Std.is(value, Int) || Std.is(value,Int))
else if(Std.isOfType(value, Int) || Std.isOfType(value,Int))
wrapper = new SFSDataWrapper(SFSDataType.INT, value);

else if(Std.is(value, Float))
else if(Std.isOfType(value, Float))
{
// Differntiate between decimal(Double)and non-decimal(Long)
if(value==Math.floor(value))
Expand All @@ -973,16 +973,16 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
wrapper = new SFSDataWrapper(SFSDataType.DOUBLE, value);
}

else if(Std.is(value, String))
else if(Std.isOfType(value, String))
wrapper = new SFSDataWrapper(SFSDataType.UTF_STRING, value);

else if(Std.is(value, Array))
else if(Std.isOfType(value, Array))
wrapper = new SFSDataWrapper(SFSDataType.SFS_ARRAY, unrollArray(value));

else if(Std.is(value, SerializableSFSType))
else if(Std.isOfType(value, SerializableSFSType))
wrapper = new SFSDataWrapper(SFSDataType.SFS_OBJECT, as2sfs(value));

else if(Std.is(value, Dynamic))
else if(Std.isOfType(value, Dynamic))
wrapper = new SFSDataWrapper(SFSDataType.SFS_OBJECT, unrollDictionary(value));

return wrapper;
Expand Down Expand Up @@ -1027,7 +1027,7 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
var theClass:Class<Dynamic> = Type.resolveClass(className);
asObj = Type.createInstance(theClass,[]);

if(!(Std.is(asObj, SerializableSFSType)))
if(!(Std.isOfType(asObj, SerializableSFSType)))
throw new SFSCodecError("Cannot deserialize object:" + asObj + ", type:" + className + " -- It doesn't implement the SerializableSFSType Interface");

//trace("CLASS:" + className)
Expand Down Expand Up @@ -1145,19 +1145,19 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
// Call recursively
_scanGenericObject(item, subSfso, forceToNumber);
}
else if(Std.is(item, Array))
else if(Std.isOfType(item, Array))
sfso.putSFSArray(key, genericArrayToSFSArray(item, forceToNumber));

else if(Std.is(item, Bool))
else if(Std.isOfType(item, Bool))
sfso.putBool(key, item);

else if(Std.is(item, Int) && !forceToNumber)
else if(Std.isOfType(item, Int) && !forceToNumber)
sfso.putInt(key, item);

else if(Std.is(item, Float))
else if(Std.isOfType(item, Float))
sfso.putDouble(key, item);

else if(Std.is(item, String))
else if(Std.isOfType(item, String))
sfso.putUtfString(key, item);

}
Expand Down Expand Up @@ -1231,7 +1231,7 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
else if(Type.typeof(item) == ValueType.TObject)
sfsa.addSFSObject(genericObjectToSFSObject(item, forceToNumber));

else if(Std.is(item, Array))
else if(Std.isOfType(item, Array))
{
var subSfsa:ISFSArray = new SFSArray();
sfsa.addSFSArray(subSfsa);
Expand All @@ -1240,16 +1240,16 @@ class DefaultSFSDataSerializer implements ISFSDataSerializer
_scanGenericArray(item, subSfsa, forceToNumber);
}

else if(Std.is(item, Bool))
else if(Std.isOfType(item, Bool))
sfsa.addBool(item);

else if(Std.is(item, Int) && !forceToNumber)
else if(Std.isOfType(item, Int) && !forceToNumber)
sfsa.addInt(item);

else if(Std.is(item, Float))
else if(Std.isOfType(item, Float))
sfsa.addDouble(item);

else if(Std.is(item, String))
else if(Std.isOfType(item, String))
sfsa.addUtfString(item);

}
Expand Down

0 comments on commit 64af287

Please sign in to comment.