Skip to content

Commit

Permalink
Merge pull request #9 from youngmonkeys/dev
Browse files Browse the repository at this point in the history
update codec and handler
  • Loading branch information
tvd12 authored Aug 15, 2021
2 parents a49a99b + d483293 commit de781a1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion codec/MsgPackConstant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class MsgPackConstant
public static readonly long MAX_UINT16 = EzyMath.bin2int(16);
public static readonly long MAX_UINT32 = EzyMath.bin2long(32);

public static readonly long MIN_NEGATIVE_FIXINT = -EzyMath.bin2int(5);
public static readonly long MIN_NEGATIVE_FIXINT = -EzyMath.bin2int(5) - 1;
public static readonly long MIN_INT8 = -EzyMath.bin2int(7);
public static readonly long MIN_INT16 = -EzyMath.bin2int(15);
public static readonly long MIN_INT32 = -EzyMath.bin2int(31);
Expand Down
19 changes: 16 additions & 3 deletions handler/EzyConnectionFailureHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,31 @@ protected override sealed void process(EzyConnectionFailureEvent evt)
client.setStatus(EzyConnectionStatus.FAILURE);
if (mustReconnect)
reconnecting = client.reconnect();
if (!reconnecting)
if (reconnecting)
{
control(evt);
onReconnecting(evt);
}
else
{
onConnectionFailed(evt);
}
postHandle(evt);
}

protected virtual bool shouldReconnect(EzyConnectionFailureEvent evt)
{
return true;
}

protected virtual void control(EzyConnectionFailureEvent evt)
protected virtual void onReconnecting(EzyConnectionFailureEvent evt)
{
}

protected virtual void onConnectionFailed(EzyConnectionFailureEvent evt)
{
}

protected virtual void postHandle(EzyConnectionFailureEvent evt)
{
}
}
Expand Down
20 changes: 14 additions & 6 deletions handler/EzyDisconnectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,29 @@ protected override void process(EzyDisconnectionEvent evt)
client.setUdpStatus(EzyConnectionStatus.DISCONNECTED);
if (mustReconnect)
reconnecting = client.reconnect();
if (!reconnecting)
if (reconnecting)
{
control(evt);
onReconnecting(evt);
}
else
{
onDisconnected(evt);
}
postHandle(evt);
}

protected virtual void preHandle(EzyDisconnectionEvent evt)
{
}

protected virtual void onReconnecting(EzyDisconnectionEvent evt)
{
}

protected virtual void onDisconnected(EzyDisconnectionEvent evt)
{
}

protected virtual void postHandle(EzyDisconnectionEvent evt)
{
}
Expand All @@ -46,9 +58,5 @@ protected virtual bool shouldReconnect(EzyDisconnectionEvent evt)
return false;
return true;
}

protected virtual void control(EzyDisconnectionEvent evt)
{
}
}
}

0 comments on commit de781a1

Please sign in to comment.