
function setwsappmsg(message)
{
    document.getElementById("divwsdebug").innerHTML = message;
}

function checkSocketSupport()
{
  
try
{
    
  if ("WebSocket" in window)
  {
      setwsappmsg("Good! Browser supports web socket");
  }
  else
  {
        setwsappmsg("Sorry! Browser supports web socket");
  }
}
catch(e)
{
    alert("Error in check socket supoort. \n "+e);
}
  

}


function openSocket()
{
    try
    {
        // var url = 'ws://' + document.location.host + document.location.pathname + 'videosharing';

// var connection = new WebSocket('ws://localhost:8080/nomavenws/chat');

var connection = new WebSocket('ws://localhost:8081/nomavenws/chat');

// When the connection is open, send some data to the server

/*INFO: Grizzly Framework 1.9.36 started in: 59ms - bound to [0.0.0.0:3700]
INFO: Grizzly Framework 1.9.36 started in: 53ms - bound to [0.0.0.0:7676]
INFO: Grizzly Framework 1.9.36 started in: 67ms - bound to [0.0.0.0:4848]
INFO: Grizzly Framework 1.9.36 started in: 89ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.36 started in: 74ms - bound to [0.0.0.0:8181]*/

connection.onopen = function () {
connection.send('login:Abhijit'); // Send the message 'Ping' to the server
setwsappmsg('Message sent');
alert("Message Sent");
};
// connection.send('Turn on the light'); // Send the message 'Ping' to the server
// Log errors
connection.onerror = function (error) {
console.log('WebSocket Error ' + error);
setwsappmsg('WebSocket Error ' + error);
};
// Log messages from the server
connection.onmessage = function (e) {
console.log('Server: ' + e.data);
setwsappmsg('Server: ' + e.data);
};


    }
    catch(e)
    {
        setwsappmsg("Error in open socket = "+e);
    }
}


