Companion to go-ws-server
*** NOTE: These instructions are repeated in go-ws-server/readme.md ***
Install browserify globally, then install go-ws-client.
$ npm install -g browserify
$ npm install go-ws-client
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="./wsClientBfied.js"></script>
</head>
<body>
</body>
</html>
module.exports = (function () {
var ws = require ('go-ws-client');
var key1 = require ('go-util').key1;
var wsClient = new ws ('localhost', 8000, (msgOb) => {
console.log ('msgOb: ' + JSON.stringify (msgOb) + '\n');
var cmd = key1 (msgOb);
var msg = msgOb [cmd];
switch (cmd) {
case 'ready':
wsClient.toSrvr ({tstCmd:1});
break;
case 'srvMsg':
document.write (msg)
break;
} // end switch (cmd)
}, {verbose: true});
}());
$ browserify wsClientTst.js -o wsClientBfied.js
$ npm install go-ws-server
go-ws-server/test.js
tada!