Room infodeveloped
This commit is contained in:
parent
2f218c2f8f
commit
2a928381ec
|
@ -36,7 +36,6 @@ function Client()
|
|||
this.APNumber = 0;
|
||||
this.APShortCode = 0;
|
||||
this.APIPAddress = 0;
|
||||
|
||||
this.isProxy = false;
|
||||
this.proxyProcess = null;
|
||||
|
||||
|
|
|
@ -95,7 +95,8 @@ addService(({
|
|||
};
|
||||
Room.rooms.get(to).send([{
|
||||
from: to,
|
||||
pack: pack
|
||||
pack: pack,
|
||||
sender: client.id
|
||||
}, 'pack/room'], wom ? client.id : void 0);
|
||||
handshake && end({
|
||||
type: 'success'
|
||||
|
|
|
@ -403,7 +403,7 @@ addService(({
|
|||
break;
|
||||
}
|
||||
case 'joinroom':{
|
||||
let {name} = message;
|
||||
let {name,autoFetchInfo} = message;
|
||||
let roomId;
|
||||
for (const [_roomId,{name:RoomName}] of Room.rooms) {
|
||||
if(name == RoomName)
|
||||
|
@ -680,7 +680,7 @@ addService(({
|
|||
// Odanın varlığının kontrolü
|
||||
if(!Room.rooms.has(roomId))
|
||||
{
|
||||
end({
|
||||
return end({
|
||||
status : "fail",
|
||||
message : "NOT-FOUND-ROOM"
|
||||
})
|
||||
|
@ -692,19 +692,19 @@ addService(({
|
|||
{
|
||||
return end({
|
||||
status : "fail",
|
||||
message : "NO-jıoned-ROOM"
|
||||
message : "NO-JOINED-ROOM"
|
||||
})
|
||||
}
|
||||
room.info.set(name, value);
|
||||
|
||||
for (const [,peer] of room.clients)
|
||||
{
|
||||
peer.send([{
|
||||
from: client.id,
|
||||
room.send([
|
||||
{
|
||||
name,
|
||||
value
|
||||
},"room/info"]);
|
||||
}
|
||||
value,
|
||||
roomId:room.id
|
||||
},
|
||||
"room/info"
|
||||
], client.id);
|
||||
|
||||
return end({
|
||||
status: "success"
|
||||
|
|
|
@ -57,7 +57,7 @@ export class Connection
|
|||
this.connected = false;
|
||||
if(this.autoReconnect)
|
||||
{
|
||||
this.autoReconnectTimer = setTimeout(this.connect, this.autoReconnectTimeout)
|
||||
this.autoReconnectTimer = setTimeout(() => this.connect(), this.autoReconnectTimeout)
|
||||
}
|
||||
}
|
||||
private eventError()
|
||||
|
|
|
@ -29,7 +29,9 @@ export default class Peer extends EventTarget
|
|||
super();
|
||||
this.mwse = wsts;
|
||||
this.info = new PeerInfo(this);
|
||||
|
||||
this.on('updateinfo',(name:string,value:any) => {
|
||||
this.info.info[name] = value;
|
||||
})
|
||||
this.on('pack',(data:{type?:string,action?:IMessageSymbase,payload?:any}) => {
|
||||
if(data.type == ':rtcbase_pack:')
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ export class RoomInfo
|
|||
this.info[name] = value;
|
||||
this.room.mwse.WSTSProtocol.SendOnly({
|
||||
type: "room/setinfo",
|
||||
roomId: this.room.roomId,
|
||||
name,
|
||||
value
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ import Peer from "./Peer";
|
|||
import Room, { IRoomOptions } from "./Room";
|
||||
import WSTSProtocol, { Message } from "./WSTSProtocol";
|
||||
import WebRTC from "./WebRTC";
|
||||
//import {Gzip} from "fflate";
|
||||
export default class MWSE extends EventTarget {
|
||||
public static rtc : WebRTC;
|
||||
public server! : Connection;
|
||||
|
@ -16,6 +17,21 @@ export default class MWSE extends EventTarget {
|
|||
public peers : Map<string, Peer> = new Map();
|
||||
public virtualPressure : IPPressure;
|
||||
public me! : Peer;
|
||||
/*public static compress(message:string, callback:(e:any) => any)
|
||||
{
|
||||
let u : any= [];
|
||||
let C = new Gzip({
|
||||
level: 9,
|
||||
mem: 12
|
||||
},(stream,isLast) => {
|
||||
u.push(stream);
|
||||
if(isLast)
|
||||
{
|
||||
callback(u);
|
||||
}
|
||||
});
|
||||
C.push(new TextEncoder().encode(message), true);
|
||||
}*/
|
||||
constructor(options: IConnection){
|
||||
super();
|
||||
this.server = new Connection(options);
|
||||
|
@ -72,9 +88,9 @@ export default class MWSE extends EventTarget {
|
|||
this.peer(from, true).emit('request', scope);
|
||||
this.peer('me').emit('request', scope);
|
||||
})
|
||||
this.EventPooling.signal('pack/room',(payload : {from:string,pack:any}) => {
|
||||
let {from,pack} = payload;
|
||||
this.room(from).emit('message', pack);
|
||||
this.EventPooling.signal('pack/room',(payload : {from:string,pack:any,sender:string}) => {
|
||||
let {from,pack,sender} = payload;
|
||||
this.room(from).emit('message', pack, this.peer(sender));
|
||||
})
|
||||
this.EventPooling.signal('room/joined',(payload : {id:string,roomid:any,ownerid:string}) => {
|
||||
let {id,roomid} = payload;
|
||||
|
@ -83,6 +99,10 @@ export default class MWSE extends EventTarget {
|
|||
room.peers.set(peer.socketId as string, peer);
|
||||
room.emit('join', peer);
|
||||
})
|
||||
this.EventPooling.signal('room/info',(payload : {roomId:string,value:any,name:string}) => {
|
||||
let {roomId,name,value} = payload;
|
||||
this.room(roomId).emit('updateinfo', name,value);
|
||||
})
|
||||
this.EventPooling.signal('room/ejected',(payload : {id:string,roomid:any,ownerid:string}) => {
|
||||
let {id,roomid} = payload;
|
||||
let room = this.room(roomid);
|
||||
|
@ -135,7 +155,6 @@ export default class MWSE extends EventTarget {
|
|||
}
|
||||
let room = new Room(this);
|
||||
room.setRoomOptions(options);
|
||||
// this.rooms.set(room.roomId as string, room);
|
||||
this.emit('room');
|
||||
return room;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
/ Odaların kendi verilerinin bulunması
|
||||
> HTTP ile kişilere mesaj (request) mesaj iletimi
|
||||
> HTTP ile odalar ve kişiler hakkında veri alınabilmesi
|
||||
> Websoket ile http proxy uygulama (WSAuth)
|
||||
> Session WSAuth
|
|
@ -12,6 +12,7 @@
|
|||
"compression": "^1.7.4",
|
||||
"express": "^4.18.2",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"fflate": "^0.8.0",
|
||||
"joi": "^17.9.2",
|
||||
"knex": "^2.4.2",
|
||||
"sqlite3": "^5.1.6",
|
||||
|
@ -1768,6 +1769,11 @@
|
|||
"resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
|
||||
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.0.tgz",
|
||||
"integrity": "sha512-FAdS4qMuFjsJj6XHbBaZeXOgaypXp8iw/Tpyuq/w3XA41jjLHT8NPA+n7czH/DDhdncq0nAyDZmPeWXh2qmdIg=="
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
|
@ -4930,6 +4936,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"fflate": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.0.tgz",
|
||||
"integrity": "sha512-FAdS4qMuFjsJj6XHbBaZeXOgaypXp8iw/Tpyuq/w3XA41jjLHT8NPA+n7czH/DDhdncq0nAyDZmPeWXh2qmdIg=="
|
||||
},
|
||||
"fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
"compression": "^1.7.4",
|
||||
"express": "^4.18.2",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"fflate": "^0.8.0",
|
||||
"joi": "^17.9.2",
|
||||
"knex": "^2.4.2",
|
||||
"sqlite3": "^5.1.6",
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="tr">
|
||||
<head>
|
||||
<base href="/stream/">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>saQüt Video Streaming</title>
|
||||
<script src="http://localhost:7707/script"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script src="test.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,32 @@
|
|||
let mwse = new MWSE({
|
||||
endpoint: "ws://localhost:7707"
|
||||
});
|
||||
|
||||
mwse.scope(beginEngine);
|
||||
|
||||
async function beginEngine()
|
||||
{
|
||||
room = mwse.room({
|
||||
name: "Naber",
|
||||
joinType: "free",
|
||||
accessType: "private",
|
||||
description: "Private free joined room",
|
||||
ifexistsJoin: false,
|
||||
notifyActionEjected: true,
|
||||
notifyActionInvite: false,
|
||||
notifyActionJoined: true
|
||||
});
|
||||
try{
|
||||
await room.createRoom();
|
||||
let time = 0;
|
||||
setInterval(()=>{
|
||||
room.info.set("set time",time);
|
||||
time++;
|
||||
},1000);
|
||||
}catch{
|
||||
await room.join();
|
||||
}
|
||||
room.on('updateinfo',(name, value) => {
|
||||
console.log("read",name,value)
|
||||
})
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue