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.
This commit is contained in:
parent
bf8e8bf777
commit
eb93a04341
8 changed files with 184 additions and 4 deletions
21
front/src/iframe_api.ts
Normal file
21
front/src/iframe_api.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
}
|
||||
}, '*');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue