55 lines
904 B
HTML
55 lines
904 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>socket io frame</title>
|
|
<script src="socket.io.min.js"></script>
|
|
<script>
|
|
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<script>
|
|
function ctx() {
|
|
return window.parent.__socketIoCtx;
|
|
}
|
|
var socket = io();
|
|
|
|
socket.on('connect', function () {
|
|
if (ctx()) {
|
|
ctx().onMessage('connect', null);
|
|
}
|
|
});
|
|
|
|
socket.on('message', function (data) {
|
|
if (ctx()) {
|
|
ctx().onMessage('message', data);
|
|
}
|
|
});
|
|
|
|
socket.on('disconnect', function () {
|
|
if (ctx()) {
|
|
ctx().onMessage('disconnect', null);
|
|
}
|
|
});
|
|
|
|
socket.on('connect_error', function (error) {
|
|
if (ctx()) {
|
|
ctx().onError(error);
|
|
}
|
|
});
|
|
|
|
function sendCmd(str) {
|
|
socket.emit('message', str);
|
|
}
|
|
|
|
if (ctx().onLoad) {
|
|
ctx().onLoad();
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html> |