예제 #1
0
 public static bool isClosed(WebSocketStatus aStatus)
 {
     return(aStatus.Equals(WebSocketStatus.CLOSED));
 }
예제 #2
0
        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);
                        }
                    }
                }
            }
        }
예제 #3
0
 public static bool isConnected(WebSocketStatus aStatus)
 {
     return(aStatus.Equals(WebSocketStatus.OPENED));
 }
예제 #4
0
 public static bool isWritable(WebSocketStatus aStatus)
 {
     return(aStatus.Equals(WebSocketStatus.OPENED));
 }
예제 #5
0
 public static bool isWritable(WebSocketStatus aStatus)
 {
     return (aStatus.Equals(WebSocketStatus.OPEN));
 }
예제 #6
0
 public static bool isConnected(WebSocketStatus aStatus)
 {
     return (aStatus.Equals(WebSocketStatus.OPEN));
 }
예제 #7
0
 public static bool isClosed(WebSocketStatus aStatus)
 {
     return (aStatus.Equals(WebSocketStatus.CLOSED));
 }