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); } }
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); } }