But am getting the exception as below: Object reference issue.
if (webSocket.State == WebSocketState.Open) { //Console.WriteLine("Write some to send over to server.."); //string stringtoSend = Console.ReadLine(); string stringtoSend = txtOutgoing.Text; byte[] buffer = encoding.GetBytes(stringtoSend); await webSocket.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Binary, false, CancellationToken.None); // Console.WriteLine("Sent: " + stringtoSend); await Task.Delay(1000); }
WebSocketContext webSocketContext = null; try { // while (webSocket.State == WebSocketState.Open) WebSocket webSocket = webSocketContext.WebSocket; //Console.WriteLine("Write some to send over to server.."); //string stringtoSend = Console.ReadLine(); string stringtoSend = txtOutgoing.Text; byte[] buffer = encoding.GetBytes(stringtoSend); await webSocket.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Binary, false, CancellationToken.None); } catch (Exception ex) { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)