A WebSocket is a communication protocol that provides full-duplex communication channels over a single TCP connection. It enables real-time, bidirectional communication between a client (such as a web browser) and a server. Unlike the traditional request-response model of HTTP, where the client initiates a request and the server responds, WebSocket allows for ongoing, persistent connections that support both the server and the client to send data to each other at any time.
xxxxxxxxxx
var realWS = WebSocket;
var WebSocketSpy = spyOn(window, "WebSocket").and.callFake(function(url,protocols){
return new realWS(url,protocols);
});