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

<!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.

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 *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax