<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>websocket1.html</title>
    <script type="text/javascript">
        var wsuri = "ws://localhost:8080/mmserverengine/webSocket";
        var ws = null;
        function startWebSocket() {
            if ('WebSocket' in window)
                ws = new WebSocket(wsuri);
            else if ('MozWebSocket' in window)
                ws = new MozWebSocket(wsuri);
            else
                alert("not support");


            ws.onmessage = function(evt) {
                alert(evt.data);
            };

            ws.onclose = function(evt) {
                alert("close");
            };

            ws.onopen = function(evt) {
                alert("open");
            };
        }

        function sendMsg() {
            ws.send(document.getElementById('writeMsg').value);
        }
    </script>
</head>
<body onload="startWebSocket();">
<input type="text" id="writeMsg"/>
<input type="button" value="send" onclick="sendMsg()"/>
</body>
</html>