Here is an example of a drawup I threw together to allow dynamic row updating.

<!DOCTYPE html>
            var ClosedCaptioningSocket = new WebSocket("ws://[WANIP]:[WANPORT]/", "protocolOne")
            ClosedCaptioningSocket.onopen = function (event) 
                ClosedCaptioningSocket.send("Here's some text that the server is urgently awaiting!"); 
            ClosedCaptioningSocket.onmessage = function (event) 
                document.getElementById("HTML5CC").innerHTML +=;
                document.getElementById("HTML5CC").scrollTop = document.getElementById("HTML5CC").scrollHeight
<div id="CCDiv" name="CCDiv" style='display:none';>
Closed Captioning
    <textarea name="HTML5CC" id="HTML5CC" rows="5" cols="200" readonly="false"></textarea>

Under the hood to send the data using .NET, Create a socket and send out data once connected to something like this.

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

Leave a Reply

Your email address will not be published. Required fields are marked *