workadventure/front/src/iframe_api.ts
David Négrier eb93a04341 Adding an API for inter-iframe communication
Adds a first version of an API to communicate between an iFrame opened by WorkAdventure and WorkAdventure itself.
The first API method is a method allowing to add messages in the chat, from the iFrame.

Comes with a test file.
2021-03-04 19:00:00 +01:00

22 lines
496 B
TypeScript

interface WorkAdventureApi {
sendChatMessage(message: string, author: string): void;
}
declare var WA: WorkAdventureApi;
window.WA = {
/**
* Sends a message in the chat.
* Only the local user will receive this message.
*/
sendChatMessage(message: string, author: string) {
window.parent.postMessage({
'type': 'chat',
'data': {
'message': message,
'author': author
}
}, '*');
}
}