Room infodeveloped

This commit is contained in:
Abdussamed 2023-09-17 17:02:33 +03:00
parent 2f218c2f8f
commit 2a928381ec
15 changed files with 1661 additions and 1572 deletions

View File

@ -36,7 +36,6 @@ function Client()
this.APNumber = 0; this.APNumber = 0;
this.APShortCode = 0; this.APShortCode = 0;
this.APIPAddress = 0; this.APIPAddress = 0;
this.isProxy = false; this.isProxy = false;
this.proxyProcess = null; this.proxyProcess = null;

View File

@ -95,7 +95,8 @@ addService(({
}; };
Room.rooms.get(to).send([{ Room.rooms.get(to).send([{
from: to, from: to,
pack: pack pack: pack,
sender: client.id
}, 'pack/room'], wom ? client.id : void 0); }, 'pack/room'], wom ? client.id : void 0);
handshake && end({ handshake && end({
type: 'success' type: 'success'

View File

@ -403,7 +403,7 @@ addService(({
break; break;
} }
case 'joinroom':{ case 'joinroom':{
let {name} = message; let {name,autoFetchInfo} = message;
let roomId; let roomId;
for (const [_roomId,{name:RoomName}] of Room.rooms) { for (const [_roomId,{name:RoomName}] of Room.rooms) {
if(name == RoomName) if(name == RoomName)
@ -680,7 +680,7 @@ addService(({
// Odanın varlığının kontrolü // Odanın varlığının kontrolü
if(!Room.rooms.has(roomId)) if(!Room.rooms.has(roomId))
{ {
end({ return end({
status : "fail", status : "fail",
message : "NOT-FOUND-ROOM" message : "NOT-FOUND-ROOM"
}) })
@ -692,19 +692,19 @@ addService(({
{ {
return end({ return end({
status : "fail", status : "fail",
message : "NO-jıoned-ROOM" message : "NO-JOINED-ROOM"
}) })
} }
room.info.set(name, value); room.info.set(name, value);
for (const [,peer] of room.clients) room.send([
{ {
peer.send([{
from: client.id,
name, name,
value value,
},"room/info"]); roomId:room.id
} },
"room/info"
], client.id);
return end({ return end({
status: "success" status: "success"

View File

@ -57,7 +57,7 @@ export class Connection
this.connected = false; this.connected = false;
if(this.autoReconnect) if(this.autoReconnect)
{ {
this.autoReconnectTimer = setTimeout(this.connect, this.autoReconnectTimeout) this.autoReconnectTimer = setTimeout(() => this.connect(), this.autoReconnectTimeout)
} }
} }
private eventError() private eventError()

View File

@ -29,7 +29,9 @@ export default class Peer extends EventTarget
super(); super();
this.mwse = wsts; this.mwse = wsts;
this.info = new PeerInfo(this); 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}) => { this.on('pack',(data:{type?:string,action?:IMessageSymbase,payload?:any}) => {
if(data.type == ':rtcbase_pack:') if(data.type == ':rtcbase_pack:')
{ {

View File

@ -37,6 +37,7 @@ export class RoomInfo
this.info[name] = value; this.info[name] = value;
this.room.mwse.WSTSProtocol.SendOnly({ this.room.mwse.WSTSProtocol.SendOnly({
type: "room/setinfo", type: "room/setinfo",
roomId: this.room.roomId,
name, name,
value value
}); });

View File

@ -6,6 +6,7 @@ import Peer from "./Peer";
import Room, { IRoomOptions } from "./Room"; import Room, { IRoomOptions } from "./Room";
import WSTSProtocol, { Message } from "./WSTSProtocol"; import WSTSProtocol, { Message } from "./WSTSProtocol";
import WebRTC from "./WebRTC"; import WebRTC from "./WebRTC";
//import {Gzip} from "fflate";
export default class MWSE extends EventTarget { export default class MWSE extends EventTarget {
public static rtc : WebRTC; public static rtc : WebRTC;
public server! : Connection; public server! : Connection;
@ -16,6 +17,21 @@ export default class MWSE extends EventTarget {
public peers : Map<string, Peer> = new Map(); public peers : Map<string, Peer> = new Map();
public virtualPressure : IPPressure; public virtualPressure : IPPressure;
public me! : Peer; 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){ constructor(options: IConnection){
super(); super();
this.server = new Connection(options); this.server = new Connection(options);
@ -72,9 +88,9 @@ export default class MWSE extends EventTarget {
this.peer(from, true).emit('request', scope); this.peer(from, true).emit('request', scope);
this.peer('me').emit('request', scope); this.peer('me').emit('request', scope);
}) })
this.EventPooling.signal('pack/room',(payload : {from:string,pack:any}) => { this.EventPooling.signal('pack/room',(payload : {from:string,pack:any,sender:string}) => {
let {from,pack} = payload; let {from,pack,sender} = payload;
this.room(from).emit('message', pack); this.room(from).emit('message', pack, this.peer(sender));
}) })
this.EventPooling.signal('room/joined',(payload : {id:string,roomid:any,ownerid:string}) => { this.EventPooling.signal('room/joined',(payload : {id:string,roomid:any,ownerid:string}) => {
let {id,roomid} = payload; let {id,roomid} = payload;
@ -83,6 +99,10 @@ export default class MWSE extends EventTarget {
room.peers.set(peer.socketId as string, peer); room.peers.set(peer.socketId as string, peer);
room.emit('join', 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}) => { this.EventPooling.signal('room/ejected',(payload : {id:string,roomid:any,ownerid:string}) => {
let {id,roomid} = payload; let {id,roomid} = payload;
let room = this.room(roomid); let room = this.room(roomid);
@ -135,7 +155,6 @@ export default class MWSE extends EventTarget {
} }
let room = new Room(this); let room = new Room(this);
room.setRoomOptions(options); room.setRoomOptions(options);
// this.rooms.set(room.roomId as string, room);
this.emit('room'); this.emit('room');
return room; return room;
} }

5
incoming-features.md Normal file
View File

@ -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

11
package-lock.json generated
View File

@ -12,6 +12,7 @@
"compression": "^1.7.4", "compression": "^1.7.4",
"express": "^4.18.2", "express": "^4.18.2",
"express-basic-auth": "^1.2.1", "express-basic-auth": "^1.2.1",
"fflate": "^0.8.0",
"joi": "^17.9.2", "joi": "^17.9.2",
"knex": "^2.4.2", "knex": "^2.4.2",
"sqlite3": "^5.1.6", "sqlite3": "^5.1.6",
@ -1768,6 +1769,11 @@
"resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" "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": { "node_modules/fill-range": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "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": { "fill-range": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",

View File

@ -42,6 +42,7 @@
"compression": "^1.7.4", "compression": "^1.7.4",
"express": "^4.18.2", "express": "^4.18.2",
"express-basic-auth": "^1.2.1", "express-basic-auth": "^1.2.1",
"fflate": "^0.8.0",
"joi": "^17.9.2", "joi": "^17.9.2",
"knex": "^2.4.2", "knex": "^2.4.2",
"sqlite3": "^5.1.6", "sqlite3": "^5.1.6",

13
public/session.html Normal file
View File

@ -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>

32
public/test.js Normal file
View File

@ -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

3109
yarn.lock

File diff suppressed because it is too large Load Diff