internal void SocketOnClose(object sender, SocketCloseEventArgs e)
{
//means error on socket. If e.Exception == null means correct socket closing at session end
if (e.Exception != null)
{
if (this.OnError != null)
{
OnError(this, new ProtocolErrorEventArgs(e.Exception));
}
if (this.OnClose != null)
{
this.OnClose(this, new CloseFrameEventArgs(new CloseFrameExt() { StatusCode = (int)StatusCode.InternalError }));
}
this.handshakeFinishedEventRaised.Set();
}
else
{
if (this.OnClose != null)
{
this.OnClose(this, new CloseFrameEventArgs(new CloseFrameExt() { StatusCode = (int)StatusCode.Success }));
}
}
}