Send event and play animation with user frame
This commit is contained in:
parent
b51ce51847
commit
5a6415607d
12 changed files with 128 additions and 84 deletions
|
@ -216,6 +216,7 @@ export class IoSocketController {
|
|||
socket.roomId = message.roomId;
|
||||
socket.userId = message.userId;
|
||||
socket.name = message.name;
|
||||
socket.frame = message.frame;
|
||||
}
|
||||
|
||||
refreshUserPosition() {
|
||||
|
|
|
@ -7,5 +7,6 @@ export interface ExSocketInterface extends Socket {
|
|||
webRtcRoomId: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
frame: string;
|
||||
position: PointInterface;
|
||||
}
|
|
@ -25,6 +25,7 @@ let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server
|
|||
roomId: socket.roomId,
|
||||
position: socket.position,
|
||||
name: socket.name,
|
||||
frame: socket.frame,
|
||||
};
|
||||
let dataArray = <any>[];
|
||||
if (mapPositionUserByRoom.get(data.roomId)) {
|
||||
|
|
|
@ -2,6 +2,7 @@ export class Message {
|
|||
userId: string;
|
||||
roomId: string;
|
||||
name: string;
|
||||
frame: string;
|
||||
|
||||
constructor(data: any) {
|
||||
if (!data.userId || !data.roomId) {
|
||||
|
@ -10,13 +11,15 @@ export class Message {
|
|||
this.userId = data.userId;
|
||||
this.roomId = data.roomId;
|
||||
this.name = data.name;
|
||||
this.frame = data.frame;
|
||||
}
|
||||
|
||||
toJson() {
|
||||
return {
|
||||
userId: this.userId,
|
||||
roomId: this.roomId,
|
||||
name: this.name
|
||||
name: this.name,
|
||||
frame: this.frame
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,37 +3,38 @@ import {Message} from "../src/Model/Websocket/Message";
|
|||
|
||||
describe("Message Model", () => {
|
||||
it("should find userId and roomId", () => {
|
||||
let message = {userId: "test1", roomId: "test2", name: "foo"};
|
||||
let message = {userId: "test1", roomId: "test2", name: "foo", frame: "user"};
|
||||
let messageObject = new Message(message);
|
||||
expect(messageObject.userId).toBe("test1");
|
||||
expect(messageObject.roomId).toBe("test2");
|
||||
expect(messageObject.name).toBe("foo");
|
||||
expect(messageObject.name).toBe("user");
|
||||
})
|
||||
|
||||
it("should expose a toJson method", () => {
|
||||
let message = {userId: "test1", roomId: "test2", name: "foo"};
|
||||
let messageObject = new Message(message);
|
||||
expect(messageObject.toJson()).toEqual({userId: "test1", roomId: "test2", name: "foo"});
|
||||
})
|
||||
expect(messageObject.toJson()).toEqual({userId: "test1", roomId: "test2", name: "foo", frame: "user"});
|
||||
});
|
||||
|
||||
it("should find throw error when no userId", () => {
|
||||
let message = {roomId: "test2"};
|
||||
expect(() => {
|
||||
let messageObject = new Message(message);
|
||||
}).toThrow(new Error("userId or roomId cannot be null"));
|
||||
})
|
||||
});
|
||||
|
||||
it("should find throw error when no roomId", () => {
|
||||
let message = {userId: "test1"};
|
||||
expect(() => {
|
||||
let messageObject = new Message(message);
|
||||
}).toThrow(new Error("userId or roomId cannot be null"));
|
||||
})
|
||||
});
|
||||
|
||||
it("should find throw error when no roomId", () => {
|
||||
let message = {name: "foo"};
|
||||
expect(() => {
|
||||
let messageObject = new Message(message);
|
||||
}).toThrow(new Error("userId or roomId cannot be null"));
|
||||
})
|
||||
});
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue