Add teleport event
This commit is contained in:
parent
7b435edd71
commit
8df56204e3
@ -891,12 +891,16 @@ export class IoSocketController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public teleport(userUuid: string) {
|
public teleport(userUuid: string) {
|
||||||
const user = this.searchClientByUuid(userUuid);
|
const userSocket = this.searchClientByUuid(userUuid);
|
||||||
if(!user){
|
if (!userSocket) {
|
||||||
throw 'User not found';
|
throw 'User not found';
|
||||||
}
|
}
|
||||||
const teleportMessageMessage = new TeleportMessageMessage();
|
const teleportMessageMessage = new TeleportMessageMessage();
|
||||||
teleportMessageMessage.setMap(`/teleport/${user.userUuid}`);
|
teleportMessageMessage.setMap(`wait/${userSocket.userUuid}`);
|
||||||
user.send(teleportMessageMessage.serializeBinary().buffer, true);
|
|
||||||
|
const serverToClientMessage = new ServerToClientMessage();
|
||||||
|
serverToClientMessage.setTeleportmessagemessage(teleportMessageMessage);
|
||||||
|
|
||||||
|
userSocket.send(serverToClientMessage.serializeBinary().buffer, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,10 @@ export class ReportController extends BaseController {
|
|||||||
})
|
})
|
||||||
const param = await res.json();
|
const param = await res.json();
|
||||||
this.ioSocketController.teleport(param.userUuid);
|
this.ioSocketController.teleport(param.userUuid);
|
||||||
res.writeStatus("200 OK").end();
|
res.writeHeader('Content-Type', 'application/json');
|
||||||
|
res.writeStatus("200 OK").end(JSON.stringify({
|
||||||
|
mapUrl: `wait/${param.userUuid}`
|
||||||
|
}));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("An error happened", e)
|
console.log("An error happened", e)
|
||||||
res.writeStatus(e.status || "500 Internal Server Error").end('An error happened');
|
res.writeStatus(e.status || "500 Internal Server Error").end('An error happened');
|
||||||
|
@ -20,6 +20,12 @@ export class GlobalMessageManager {
|
|||||||
this.Connection.receiveStopGlobalMessage((messageId: string) => {
|
this.Connection.receiveStopGlobalMessage((messageId: string) => {
|
||||||
this.stopMessage(messageId);
|
this.stopMessage(messageId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//receive signal to close message
|
||||||
|
this.Connection.receiveTeleportMessage((map: string) => {
|
||||||
|
console.log('map to teleport user', map);
|
||||||
|
//TODO teleport user on map
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private playMessage(message : PlayGlobalMessageInterface){
|
private playMessage(message : PlayGlobalMessageInterface){
|
||||||
|
Loading…
Reference in New Issue
Block a user