I do not think that is so sought after. Most people prefer products WebRTC.
Also on the good reason of using WebRTC instead of WebSocket is the latency of streaming.
Is the protocol for two-way communication with a remote host.
The WebSocket interface and defines a full-duplex communication channel and operates through a single socket over the Web. The WebSocket detects the presence of a proxy server.
The next step is to automatically set up a tunnel to pass through the proxy.
The tunnel is established by issuing an HTTP CONNECT statement to the proxy server.
Let’s see one simple example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | <!DOCTYPE html> <meta charset="utf-8" /> <title>Tutorial free-tutorials.org - testing websocket</title> <script language="javascript" type="text/javascript"> var wsUri = "ws://echo.websocket.org/"; var output; function init() { output = document.getElementById("output"); test_web_socket(); } function test_web_socket() { websocket = new WebSocket(wsUri); websocket.onopen = function(evt) { onOpen(evt) }; websocket.onclose = function(evt) { onClose(evt) }; websocket.onmessage = function(evt) { onMessage(evt) }; websocket.onerror = function(evt) { onError(evt) }; } function onOpen(evt) { screen_output("open connection"); doSend("websocket working"); } function onClose(evt) { screen_output("close connection"); } function onMessage(evt) { screen_output('<span style="color: blue;">reply: ' + evt.data+'</span>'); websocket.close(); } function onError(evt) { screen_output('<span style="color: red;">error is:</span> ' + evt.data); } function doSend(message) { screen_output("message is: " + message); websocket.send(message); } function screen_output(message) { var pre = document.createElement("p"); pre.style.wordWrap = "break-word"; pre.innerHTML = message; output.appendChild(pre); } window.addEventListener("load", init, false); </script> <h2>tutorial about websocket test</h2> <div id="output"></div> |
It is one simple open and close and sending a message with WebSocket and javascript show events.
The most important part is to define the WebSocket:
1 2 3 4 5 | websocket = new WebSocket(wsUri); websocket.onopen = function(evt) { onOpen(evt) }; websocket.onclose = function(evt) { onClose(evt) }; websocket.onmessage = function(evt) { onMessage(evt) }; websocket.onerror = function(evt) { onError(evt) }; |
The next steps are to use it with the default javascript event system and window show message.