Beispiel #1
0
        public Task Connect()
        {
            int ret = WebSocketConnect(this.instanceId);

            if (ret < 0)
            {
                throw WebSocketHelpers.GetErrorMessageFromCode(ret, null);
            }

            return(Task.CompletedTask);
        }
Beispiel #2
0
        public Task Send(byte[] data)
        {
            int ret = WebSocketSend(this.instanceId, data, data.Length);

            if (ret < 0)
            {
                throw WebSocketHelpers.GetErrorMessageFromCode(ret, null);
            }

            return(Task.CompletedTask);
        }
Beispiel #3
0
        public Task SendText(string message)
        {
            int ret = WebSocketSendText(this.instanceId, message);

            if (ret < 0)
            {
                throw WebSocketHelpers.GetErrorMessageFromCode(ret, null);
            }

            return(Task.CompletedTask);
        }
Beispiel #4
0
        public Task Close(WebSocketCloseCode code = WebSocketCloseCode.Normal, string reason = null)
        {
            int ret = WebSocketClose(this.instanceId, (int)code, reason);

            if (ret < 0)
            {
                throw WebSocketHelpers.GetErrorMessageFromCode(ret, null);
            }

            return(Task.CompletedTask);
        }