public void Connect() { int response = Connect(this.instanceId); if (response < 0) { throw ErrorParser.GetWebSocketExceptionFromErrorCode(response, null); } }
public void Close(DisconnectCode code = DisconnectCode.Normal, string reason = null) { int response = Close(instanceId, (int)code, reason); if (response < 0) { throw ErrorParser.GetWebSocketExceptionFromErrorCode(response, null); } }
public void Send(ArraySegment <byte> payload) { int response = Send(instanceId, payload.Array, payload.Offset, payload.Count); if (response < 0) { throw ErrorParser.GetWebSocketExceptionFromErrorCode(response, null); } }
public WebSocketState GetState() { int state = GetState(instanceId); if (state < 0) { throw ErrorParser.GetWebSocketExceptionFromErrorCode(state, null); } switch (state) { case 0: { return(WebSocketState.Connecting); } case 1: { return(WebSocketState.Open); } case 2: { return(WebSocketState.Closing); } case 3: { return(WebSocketState.Closed); } default: { return(WebSocketState.Closed); } } }