public static bool isClosed(WebSocketStatus aStatus) { return(aStatus.Equals(WebSocketStatus.CLOSED)); }
private void ProcessHybi() { WebSocketFrameType lFrameType; IWebSocketPacket lPacket; while (mIsRunning) { try { lPacket = WebSocketProtocolAbstraction.protocolToRawPacket(mNetStream); Console.WriteLine(lPacket.GetString()); lFrameType = (lPacket != null ? lPacket.FrameType : WebSocketFrameType.INVALID); if (lFrameType.Equals(null)) { if (mLog.IsErrorEnabled) { mLog.Error(WebSocketMessage.NULL_FRAME_TYPE); } mIsRunning = false; mCLose = WebSocketCloseReason.BROKEN; OnError(new WebSocketError(WebSocketMessage.NULL_FRAME_TYPE, mCLose)); } else if (lFrameType.Equals(WebSocketFrameType.INVALID)) { if (mLog.IsErrorEnabled) { mLog.Error(WebSocketMessage.INVALID_HYBI_FRAME); } mIsRunning = false; mCLose = WebSocketCloseReason.BROKEN; OnError(new WebSocketError(WebSocketMessage.INVALID_HYBI_FRAME, mCLose)); } else if (lFrameType.Equals(WebSocketFrameType.CLOSE)) { if (mLog.IsInfoEnabled) { mLog.Info(WebSocketMessage.CLOSE_FRAME_TYPE); } mIsRunning = false; mCLose = WebSocketCloseReason.CLIENT; StopIt(); } else if (lFrameType.Equals(WebSocketFrameType.PONG)) { OnRecivePong(); if (WebSocketStateOfStatus.isWritable(mStatus)) { if (mLog.IsInfoEnabled) { mLog.Info(WebSocketMessage.PING_PACKET_SENDING); } Ping(); OnSendPing(); } } else if (lFrameType.Equals(WebSocketFrameType.BINARY)) { if (mLog.IsInfoEnabled) { mLog.Info(WebSocketMessage.BINARY_PACKET_RECEIVED); } //****TODO**** } else if (lFrameType.Equals(WebSocketFrameType.TEXT)) { if (mLog.IsInfoEnabled) { mLog.Info(WebSocketMessage.TEXT_PACKET_RECEIVED); } OnReciveTextPacket(this, lPacket); } else if (lFrameType.Equals(WebSocketFrameType.FRAGMENT)) { if (mLog.IsInfoEnabled) { mLog.Info(WebSocketMessage.FRAGMENT_PACKET_RECEIVED); } //****TODO**** } } catch (Exception lEx) { mIsRunning = false; if (mStatus.Equals(WebSocketStatus.CLOSED)) { mCLose = WebSocketCloseReason.CLIENT; } else { mCLose = WebSocketCloseReason.BROKEN; OnError(new WebSocketError(WebSocketMessage.ERROR_HYBI_PROCESSOR, mCLose)); if (mLog.IsErrorEnabled) { mLog.Error(WebSocketMessage.ERROR_HYBI_PROCESSOR + WebSocketMessage.SEPARATOR + lEx.Message); } } } } }
public static bool isConnected(WebSocketStatus aStatus) { return(aStatus.Equals(WebSocketStatus.OPENED)); }
public static bool isWritable(WebSocketStatus aStatus) { return(aStatus.Equals(WebSocketStatus.OPENED)); }
public static bool isWritable(WebSocketStatus aStatus) { return (aStatus.Equals(WebSocketStatus.OPEN)); }
public static bool isConnected(WebSocketStatus aStatus) { return (aStatus.Equals(WebSocketStatus.OPEN)); }
public static bool isClosed(WebSocketStatus aStatus) { return (aStatus.Equals(WebSocketStatus.CLOSED)); }