Name of map users
- Add name on user - Delete NonPlayer class not used
This commit is contained in:
parent
8355a89dc5
commit
b65e37c468
10 changed files with 46 additions and 65 deletions
|
@ -215,6 +215,7 @@ export class IoSocketController {
|
|||
socket.position = message.position;
|
||||
socket.roomId = message.roomId;
|
||||
socket.userId = message.userId;
|
||||
socket.name = message.name;
|
||||
}
|
||||
|
||||
refreshUserPosition() {
|
||||
|
|
|
@ -6,5 +6,6 @@ export interface ExSocketInterface extends Socket {
|
|||
roomId: string;
|
||||
webRtcRoomId: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
position: PointInterface;
|
||||
}
|
|
@ -9,27 +9,28 @@ 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) {
|
||||
let clients = Io.clients();
|
||||
let socketsKey = Object.keys(Io.clients().sockets);
|
||||
|
||||
//create mapping with all users in all rooms
|
||||
let mapPositionUserByRoom = new Map();
|
||||
for(let i = 0; i < socketsKey.length; i++){
|
||||
for (let i = 0; i < socketsKey.length; i++) {
|
||||
let socket = clients.sockets[socketsKey[i]] as ExSocketInterface;
|
||||
if(!socket.position){
|
||||
if (!socket.position) {
|
||||
continue;
|
||||
}
|
||||
let data = {
|
||||
userId : socket.userId,
|
||||
roomId : socket.roomId,
|
||||
position : socket.position,
|
||||
userId: socket.userId,
|
||||
roomId: socket.roomId,
|
||||
position: socket.position,
|
||||
name: socket.name,
|
||||
};
|
||||
let dataArray = <any>[];
|
||||
if(mapPositionUserByRoom.get(data.roomId)){
|
||||
if (mapPositionUserByRoom.get(data.roomId)) {
|
||||
dataArray = mapPositionUserByRoom.get(data.roomId);
|
||||
dataArray.push(data);
|
||||
}else{
|
||||
} else {
|
||||
dataArray = [data];
|
||||
}
|
||||
mapPositionUserByRoom.set(data.roomId, dataArray);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
export class Message {
|
||||
userId: string;
|
||||
roomId: string;
|
||||
name: string;
|
||||
|
||||
constructor(data: any) {
|
||||
if (!data.userId || !data.roomId) {
|
||||
|
@ -8,12 +9,14 @@ export class Message {
|
|||
}
|
||||
this.userId = data.userId;
|
||||
this.roomId = data.roomId;
|
||||
this.name = data.name;
|
||||
}
|
||||
|
||||
toJson() {
|
||||
return {
|
||||
userId: this.userId,
|
||||
roomId: this.roomId
|
||||
roomId: this.roomId,
|
||||
name: this.name
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue