Update video style and start peer connexion
This commit is contained in:
parent
dbf0bef149
commit
e06b20fe96
7 changed files with 140 additions and 131 deletions
|
@ -1,19 +1,25 @@
|
|||
import {MessageUserPosition} from "./Websocket/MessageUserPosition";
|
||||
import { World } from "./World";
|
||||
import { UserInterface } from "./UserInterface";
|
||||
import {uuid} from "uuidv4";
|
||||
|
||||
export class Group {
|
||||
static readonly MAX_PER_GROUP = 4;
|
||||
|
||||
private id: string;
|
||||
private users: UserInterface[];
|
||||
private connectCallback: (user1: string, user2: string) => void;
|
||||
private disconnectCallback: (user1: string, user2: string) => void;
|
||||
private connectCallback: (user1: string, user2: string, group: Group) => void;
|
||||
private disconnectCallback: (user1: string, user2: string, group: Group) => void;
|
||||
|
||||
|
||||
constructor(users: UserInterface[], connectCallback: (user1: string, user2: string) => void, disconnectCallback: (user1: string, user2: string) => void) {
|
||||
constructor(users: UserInterface[],
|
||||
connectCallback: (user1: string, user2: string, group: Group) => void,
|
||||
disconnectCallback: (user1: string, user2: string, group: Group) => void
|
||||
) {
|
||||
this.users = [];
|
||||
this.connectCallback = connectCallback;
|
||||
this.disconnectCallback = disconnectCallback;
|
||||
this.id = uuid();
|
||||
|
||||
users.forEach((user: UserInterface) => {
|
||||
this.join(user);
|
||||
|
@ -24,6 +30,10 @@ export class Group {
|
|||
return this.users;
|
||||
}
|
||||
|
||||
getId() : string{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
isFull(): boolean {
|
||||
return this.users.length >= Group.MAX_PER_GROUP;
|
||||
}
|
||||
|
@ -31,9 +41,10 @@ export class Group {
|
|||
join(user: UserInterface): void
|
||||
{
|
||||
// Broadcast on the right event
|
||||
this.users.forEach((groupUser: UserInterface) => {
|
||||
this.connectCallback(user.id, groupUser.id);
|
||||
});
|
||||
for(let i = 0; i < this.users.length; i++){
|
||||
let groupUser : UserInterface = this.users[i];
|
||||
this.connectCallback(user.id, groupUser.id, this);
|
||||
}
|
||||
this.users.push(user);
|
||||
user.group = this;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue