Loading...   


<script src="jquery.min.js"></script>
<script type='text/javascript'>
    var connection = new WebSocket('ws://localhost:9002');

	// When the connection is open, send some data to the server
	connection.onopen = function () {
		// for (i = 0; i <= 1000; i++) { 
		// 	connection.send('Testing: ' + i); // Send the message 'Ping' to the server
		// }
		connection.send('This is a test message');
	};

	// Log errors
	connection.onerror = function (error) {
	  console.log('WebSocket Error ' + error);
	};

	// Log messages from the server
	connection.onmessage = function (e) {
	  console.log('Server: ' + e.data);
	};
	
	function SendMessage(){
		connection.send($( "#text_field" ).val());
	}

</script> 

<textarea id="text_field" style="width:100%; height:400px"></textarea>

<a href="javascript:;" onclick="SendMessage()">Send Test Message</a>

Raw Paste Data