|
|
- <!DOCTYPE html>
- <html>
- <head>
- <title>Hello world</title>
- </head>
- <script src = "../../socket.io/socket.io.js"></script>
-
- <script>
- var socket = io();
- socket.emit('register', 'jeff');
-
- var join = function(name)
- {
- var obj = new Object();
- obj.roomName = name;
- obj.password = '';
- socket.emit('joinRoom', obj);
- }
-
- socket.on('sendRooms', function(data)
- {
- console.log("got rooms");
- console.log(data);
- //document.write(data);
-
- data.rooms.forEach(function(r)
- {
- document.write("<input type=\"submit\" value=\"Join Room" + r.name + "\" onclick=\"join(\"" + r.name + "\")\">");
- document.write(r.name)
- document.write("<br />");
- });
- var tt = new Object();
- tt.roomName = "den";
- tt.password = "pp";
- socket.emit('createRoom', tt);
- });
-
- socket.on('roomUpdate', function(data)
- {
- console.log("good");
- console.log(data);
- });
-
-
- </script>
- <body>Hello world</body>
- </html>
|