Merge pull request #82 from thecodingmachine/fix/webrtc

Fix webrtc
This commit is contained in:
David Négrier 2020-05-08 16:14:49 +02:00 committed by GitHub
commit 25b7fc5e36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 837 additions and 814 deletions

View File

@ -91,9 +91,6 @@ export class IoSocketController {
return socket.emit(SockerIoEvent.MESSAGE_ERROR, JSON.stringify({message: messageUserPosition.message}));
}
// update position in the worl
this.World.updatePosition(messageUserPosition);
// sending to all clients in room except sender
this.saveUserInformation((socket as ExSocketInterface), messageUserPosition);
@ -172,6 +169,9 @@ export class IoSocketController {
Client.broadcast.emit(SockerIoEvent.WEBRTC_DISCONNECT, JSON.stringify({
userId: Client.userId
}));
//disconnect webrtc room
Client.leave(Client.webRtcRoomId);
}
/**
@ -186,11 +186,11 @@ export class IoSocketController {
socket.join(roomId);
socket.webRtcRoomId = roomId;
//if two persone in room share
if (this.Io.sockets.adapter.rooms[roomId].length < 2) {
if (this.Io.sockets.adapter.rooms[roomId].length < 2 || this.Io.sockets.adapter.rooms[roomId].length >= 4) {
return;
}
let clients: Array<any> = Object.values(this.Io.sockets.sockets);
let clients: Array<ExSocketInterface> = (Object.values(this.Io.sockets.sockets) as Array<ExSocketInterface>)
.filter((client: ExSocketInterface) => client.webRtcRoomId && client.webRtcRoomId === roomId);
//send start at one client to initialise offer webrtc
//send all users in room to create PeerConnection in front
clients.forEach((client: ExSocketInterface, index: number) => {
@ -225,7 +225,7 @@ export class IoSocketController {
if (!rooms.refreshUserPosition) {
rooms.refreshUserPosition = RefreshUserPositionFunction;
}
rooms.refreshUserPosition(rooms, this.Io);
rooms.refreshUserPosition(rooms, this.Io, this.World);
}
//Hydrate and manage error

View File

@ -1,6 +1,8 @@
import {ExtRoomsInterface} from "./ExtRoomsInterface";
import socketIO = require('socket.io');
import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface";
import {ExSocketInterface} from "./ExSocketInterface";
import {MessageUserPosition} from "./MessageUserPosition";
import {World} from "_Model/World";
export class ExtRooms implements ExtRoomsInterface{
userPositionMapByRoom: any;
@ -9,7 +11,7 @@ export class ExtRooms implements ExtRoomsInterface{
[room: string]: SocketIO.Room;
}
let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server) {
let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server, World : World) {
let clients = Io.clients();
let socketsKey = Object.keys(Io.clients().sockets);
@ -35,6 +37,10 @@ let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server
dataArray = [data];
}
mapPositionUserByRoom.set(data.roomId, dataArray);
// update position in the worl
let messageUserPosition = new MessageUserPosition(data);
World.updatePosition(messageUserPosition);
}
rooms.userPositionMapByRoom = Array.from(mapPositionUserByRoom);
}

1142
front/dist/maps/map.json vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,254 +1,224 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.2" tiledversion="1.3.3" name="office_1" tilewidth="32" tileheight="32" tilecount="256" columns="16">
<image source="tilesets_deviant_milkian_1.png" width="512" height="512"/>
<tile id="7">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="12">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="13">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="14">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="15">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="23">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="28">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="29">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="30">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="31">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="39">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="44">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="45">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="48">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="49">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="50">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="51">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="52">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="56">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="57">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="64">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="65">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="66">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="67">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="68">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="72">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="73">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="84">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="152">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="153">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="154">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="155">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="156">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="157">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="161">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="162">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="168">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="169">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="170">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="171">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="172">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="173">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="177">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="178">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="184">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="185">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="186">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="196">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="198">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="214">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
</tileset>
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.2" tiledversion="1.3.3" name="office_1" tilewidth="32" tileheight="32" tilecount="256" columns="16">
<image source="tilesets_deviant_milkian_1.png" width="512" height="512"/>
<tile id="7">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="14">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="15">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="23">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="28">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="29">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="30">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="31">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="39">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="48">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="49">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="50">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="51">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="52">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="64">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="65">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="66">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="67">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="68">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="72">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="73">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="84">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="152">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="153">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="154">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="155">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="156">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="157">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="161">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="162">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="168">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="169">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="170">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="171">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="172">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="173">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="177">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="178">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="184">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="185">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="186">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="196">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="198">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
<tile id="214">
<properties>
<property name="collides" type="bool" value="true"/>
</properties>
</tile>
</tileset>

View File

@ -89,7 +89,12 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
this.Layers = new Array<Phaser.Tilemaps.StaticTilemapLayer>();
let depth = -2;
this.map.layers.forEach((layer) => {
if (layer.type === 'tilelayer') {
if (layer.type === 'tilelayer' && layer.name === "override") {
let tab : Array<any> = (layer.properties as any);
let propertiesDepth = tab.find((props : any) => props.name === "depth");
this.addLayer( this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(propertiesDepth ? propertiesDepth.value : 2) );
}
else if (layer.type === 'tilelayer') {
this.addLayer( this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth) );
} else if (layer.type === 'objectgroup' && layer.name === 'floorLayer') {
depth = -1;