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:
@@ -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
|
||||
}
|
||||
}, '*');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user