MWSE/script/test.html

69 lines
2.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2><pre id="log"></pre></h2>
<h1 id="message"></h1>
<script src="http://localhost:7707/script"></script>
<script>
async function main(){
const wsjs = new MWSE({
endpoint: "ws://localhost:7707"
});
wsjs.scope(async ()=>{
let me = wsjs.peer('me');
me.disablePairAuth();
console.log(me.socketId);
let room = wsjs.room({
accessType: "public",
description: "Benim odam",
joinType: "free",
name: "M.E.",
notifyActionInvite: true,
notifyActionJoined: true,
notifyActionEjected: false,
ifexistsJoin: true
});
room.on('updateinfo',(name,value) => {
console.log(`Odanın ${name} özelliği ${value} olarak değişti`)
})
window.room = room;
await room.createRoom();
room.on('message',(...args)=>{
gg.r++
gg()
console.log(args[0],gg.r)
});
iroom = room;
setInterval(()=>{
room.send({
type: "merhaba"
})
gg.w++;
gg()
}, 2000)
});
};
function gg()
{
log.innerHTML = `${gg.w} packet writed\n${gg.r} packet recaived`
}
gg.w = 0;
gg.r = 0;
/*setInterval(()=>{
window.location.reload();
}, 30000)*/
main();
</script>
</body>
</html>