代码拉取完成,页面将自动刷新
<!doceventname html>
<html>
<head>
<title>socket.io chat</title>
<link rel="shortcut icon" href="#" />
</head>
<body>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket;
function connect(nsp, username) {
socket = io("/" + nsp);
socket.on('connect', function () {
// var data ={};
// data.eventname="connected";
// setWebViewString(data);
socket.emit("login", username);
});
socket.on('disconnect', function (reason) {
var data = {};
data.eventname = "disconnected";
data.reason = reason;
setWebViewString(data);
});
socket.on("connected", function (data) {
setWebViewString(data);
});
socket.on("matched", function (data) {
setWebViewString(data);
});
socket.on("gotRoomMessage", function (data) {
setWebViewString(data);
});
socket.on("gotPrivateMessage", function (data) {
setWebViewString(data);
});
socket.on("gotPublicMessage", function (data) {
setWebViewString(data);
});
socket.on("joinedRoom", function (data) {
setWebViewString(data);
});
socket.on("otherJoinedRoom", function (data) {
setWebViewString(data);
});
socket.on("leftRoom", function (data) {
setWebViewString(data);
});
socket.on("otherLeftRoom", function (data) {
setWebViewString(data);
});
socket.on("gotError", function (data) {
setWebViewString(data);
});
}
// function login(username){
// socket.emit("login", username);
// }
function startMatch() {
socket.emit("startMatch");
}
function cancelMatch() {
socket.emit("cancelMatch");
}
function sendRoomMessage(roomname, message) {
socket.emit("sendRoomMessage", roomname, message);
}
function sendPrivateMessage(receiver, message) {
socket.emit("sendPrivateMessage", receiver, message);
}
function sendPublicMessage(message) {
socket.emit("sendPublicMessage", message);
}
function leaveRoom(roomname) {
socket.emit("leaveRoom", roomname);
}
function joinRoom(roomname) {
socket.emit("joinRoom", roomname);
}
function disconnect() {
socket.close();
}
function setMaxUser(maxuser) {
socket.emit("setMaxUser", maxuser);
}
function setWebViewString(d) {
if (window.AppInventor) {
window.AppInventor.setWebViewString(JSON.stringify(d));
}
console.log(d);
}
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。