No announcement yet.

Html5 - bidirectional communication

  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Hello, JorgeCosta87

    Follow this step,To Html5 - bidirectional communication

    First, what you do is create a Web Socket object with a URL to where you want to establish a connection to:

    HTML Code:
    var ws = new WebSocket("ws://");
    You have a couple of useful methods:
    view sourceprint?
    HTML Code:
    // Send data
    ws.send("Some data");
    // Close the connection
    And to complement that, there are a number of events:
    HTML Code:
    // When connection is opened?
    ws.onopen = function () {
    console.log("Connection opened!");
    // When you receive a message
    ws.onmessage = function (evt) {
    // When the connections is closed
    ws.onclose = function () {
    console.log("Connection closed");
    // When an error occurred
    ws.onerror = function () {
    console.log("An error occurred");
    I hope this information will be usefull for you.
    Thank You.

    Leave a comment:

  • started a topic Html5 - bidirectional communication

    Html5 - bidirectional communication

    How to exchange messages from HTML page to unreal element and vice-versa?

    Best regards, Jorge Costa