lib/wsm.js
function wsConnect() {

            var typeOfConnection;

            if (location.protocol === 'https:') {
                typeOfConnection = 'wss';
            } else {
                typeOfConnection = 'ws'
            }

            self.ws = new WebSocket(typeOfConnection + '://' + location.hostname + ':' + location.port);

            self.ws.onopen = function (event) {

                //send an intial message to server and prove that the connection is built.
                self.send('connected', 'WSM: Browser confirms websocket connection.')

                reactive(self);

            };

            self.ws.onmessage = function (event) {
                // flags.binary will be set if a binary data is received.
                // flags.masked will be set if the data was masked.
                //console.log(event.data);

                self.processMessage(JSON.parse(event.data));
            };

            self.ws.onclose = function (event) {

                wsConnect();
            }
        }
function wsConnect() {

            var typeOfConnection;

            if (location.protocol === 'https:') {
                typeOfConnection = 'wss';
            } else {
                typeOfConnection = 'ws'
            }

            self.ws = new WebSocket(typeOfConnection + '://' + location.hostname + ':' + location.port);

            self.ws.onopen = function (event) {

                //send an intial message to server and prove that the connection is built.
                self.send('connected', 'WSM: Browser confirms websocket connection.')

                reactive(self);

            };

            self.ws.onmessage = function (event) {
                // flags.binary will be set if a binary data is received.
                // flags.masked will be set if the data was masked.
                //console.log(event.data);

                self.processMessage(JSON.parse(event.data));
            };

            self.ws.onclose = function (event) {

                wsConnect();
            }
        }
function wsConnect ( ) { var typeOfConnection ; if ( location . protocol === 'https:' ) { typeOfConnection = 'wss' ; } else { typeOfConnection = 'ws' } self . ws = new WebSocket ( typeOfConnection + '://' + location . hostname + ':' + location . port ) ; self . ws . onopen = function ( event ) { //send an intial message to server and prove that the connection is built. self . send ( 'connected' , 'WSM: Browser confirms websocket connection.' ) reactive ( self ) ; } ; self . ws . onmessage = function ( event ) { // flags.binary will be set if a binary data is received. // flags.masked will be set if the data was masked. //console.log(event.data); self . processMessage ( JSON . parse ( event . data ) ) ; } ; self . ws . onclose = function ( event ) { wsConnect ( ) ; } }
on browser 
wrap browser's websocket connection into one function, if the connection drop or close, try to reconnect itself.
on browser wrap browser s websocket connection into one function if the connection drop or close try to reconnect itself .