Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle the emit in try/catch #47

Merged
merged 2 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Src/EngineIoClientDotNet.mono/Client/Socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ private bool Flush()
var log = LogManager.GetLogger(Global.CallerName());

log.Info(string.Format("ReadyState={0} Transport.Writeable={1} Upgrading={2} WriteBuffer.Count={3}",ReadyState,Transport.Writable,Upgrading, WriteBuffer.Count));
if (ReadyState != ReadyStateEnum.CLOSED && this.Transport.Writable && !Upgrading && WriteBuffer.Count != 0)
if (ReadyState != ReadyStateEnum.CLOSED && ReadyState == ReadyStateEnum.OPEN && this.Transport.Writable && !Upgrading && WriteBuffer.Count != 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be shortened:
if ReadyState == ReadyStateEnum.OPEN has to be true ReadyState != ReadyStateEnum.CLOSED is always true, the first condition is not needed

{
log.Info(string.Format("Flush {0} packets in socket", WriteBuffer.Count));
PrevBufferLen = WriteBuffer.Count;
Expand Down
13 changes: 9 additions & 4 deletions Src/EngineIoClientDotNet.mono/ComponentEmitter/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ public virtual Emitter Emit(string eventString, params object[] args)
//log.Info("Emitter emit event = " + eventString);
if (this.callbacks.ContainsKey(eventString))
{
ImmutableList<IListener> callbacksLocal = this.callbacks[eventString];
foreach (var fn in callbacksLocal)
try
{
fn.Call(args);
}
//handle in try/catch the emit
ImmutableList<IListener> callbacksLocal = this.callbacks[eventString];
foreach (var fn in callbacksLocal)
{
fn.Call(args);
}
}
catch { }
}
return this;
}
Expand Down