1 Star 0 Fork 1

浮云/socketio-aix

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
浮云 提交于 2023-03-04 10:01 . bugfix
<!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>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ainote/socketio-aix.git
git@gitee.com:ainote/socketio-aix.git
ainote
socketio-aix
socketio-aix
master

搜索帮助