Websocket with javascript


So basically I want to create websocket from api that need using websocket to create some alert, so far I have try using ClientWebsocket and it work as I expected but sometimes not, something like this

public static async Task<ListenerContent> ConnectCall(string uri, string valcookie, string xapp, string listenerName, string terminalId, string userCrm)
        ClientWebSocket webSocket = null;
        var objListener = new ListenerContent();
            webSocket = new ClientWebSocket();
            webSocket.Options.SetRequestHeader("Cookie", valcookie);
            await webSocket.ConnectAsync(new Uri(uri), CancellationToken.None);
            var terminalListener = CreateListener(xapp, listenerName);
            RetrieveCurrentCalls(xapp, listenerName, terminalId);
            objListener = JsonConvert.DeserializeObject<ListenerContent>(terminalListener);
            await Task.WhenAll(Receive(webSocket, terminalId, userCrm), Send(webSocket));
        catch (Exception ex)
            Console.WriteLine("Exception in receive - {0}", ex.Message);
            if (webSocket != null)

            lock (consoleLock)
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("WebSocket closed.");
        return objListener;

so I want to ask about is there any other way to connect this socket with javascript or other library, because I use this with console application and not really smooth

Show source
| javascript   | asp.net   | c#   | .net   | websocket   2017-05-11 23:05 0 Answers

Answers to Websocket with javascript ( 0 )

Leave a reply to - Websocket with javascript

◀ Go back