Here is an example of a drawup I threw together to allow dynamic row updating.
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 |
<!DOCTYPE html> <html> <head> <script> var ClosedCaptioningSocket = new WebSocket("ws://[WANIP]:[WANPORT]/", "protocolOne") ClosedCaptioningSocket.onopen = function (event) { ClosedCaptioningSocket.send("Here's some text that the server is urgently awaiting!"); document.getElementById("CCDiv").style.display='block'; }; ClosedCaptioningSocket.onmessage = function (event) { document.getElementById("HTML5CC").innerHTML += event.data; document.getElementById("HTML5CC").scrollTop = document.getElementById("HTML5CC").scrollHeight } </script> </head> <body> <div id="CCDiv" name="CCDiv" style='display:none';> <br><br> Closed Captioning <br> <textarea name="HTML5CC" id="HTML5CC" rows="5" cols="200" readonly="false"></textarea> </div> </body> </html> |
Under the hood to send the data using .NET, Create a socket and send out data once connected to something like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Public Sub SendData(Data As String) Dim Stream As NetworkStream = _TcpClient.GetStream() Dim DataToSend As Byte() = System.Text.Encoding.UTF8.GetBytes(Data) Dim FRRROPCODE As Byte = Convert.ToByte("10000001", 2) 'FIN is set, and OPCODE is 1 or Text Dim header As Byte() = {FRRROPCODE, Convert.ToByte(DataToSend.Length)} Dim ResponseData As Byte() ReDim ResponseData((header.Length + DataToSend.Length) - 1) 'NOTEWORTHY: if you Redim ResponseData(header.length + Payload.Length).. you'll add a 0 value byte at the end of the response data.. 'which tells the client that your next stream write will be a continuation frame.. Dim index As Integer = 0 Buffer.BlockCopy(header, 0, ResponseData, index, header.Length) index += header.Length Buffer.BlockCopy(DataToSend, 0, ResponseData, index, DataToSend.Length) index += DataToSend.Length Stream.Write(ResponseData, 0, ResponseData.Length) End Sub |