WriteFrame() 공개 메소드

public WriteFrame ( WsFrame frame ) : bool
frame WsFrame
리턴 bool
예제 #1
0
        private bool send(WsFrame frame)
        {
            if (_readyState == WsState.CONNECTING ||
                _readyState == WsState.CLOSED)
            {
                onError("The WebSocket connection isn't established or has been closed.");
                return(false);
            }

            try
            {
                if (_wsStream.IsNull())
                {
                    return(false);
                }

                _wsStream.WriteFrame(frame);
                return(true);
            }
            catch (Exception ex)
            {
                onError(ex.Message);
                return(false);
            }
        }
예제 #2
0
파일: WebSocket.cs 프로젝트: yankaics/cms-1
        private bool send(WsFrame frame)
        {
            if (_readyState == WsState.CONNECTING ||
                _readyState == WsState.CLOSED)
            {
                var msg = "The WebSocket connection isn't established or has been closed.";
                onError(msg);
                return(false);
            }

            try
            {
                if (_unTransmittedBuffer.Count == 0)
                {
                    if (_wsStream != null)
                    {
                        _wsStream.WriteFrame(frame);
                        return(true);
                    }
                }

                if (_unTransmittedBuffer.Count > 0)
                {
                    _unTransmittedBuffer.Add(frame);
                    var msg = "Current data can not be sent because there is untransmitted data.";
                    onError(msg);
                }

                return(false);
            }
            catch (Exception ex)
            {
                _unTransmittedBuffer.Add(frame);
                onError(ex.Message);
                return(false);
            }
        }