Confirmed users
110
edits
m (→Caller) |
|||
| Line 169: | Line 169: | ||
connect('musictrack').then(function onConnectionAccepted(ports) { | connect('musictrack').then(function onConnectionAccepted(ports) { | ||
// If the connection is allowed at least by one peer, the resolved callback | // If the connection is allowed at least by one peer, the resolved callback | ||
// will be triggered with a list of | // will be triggered with a list of InterAppMessagePorts as parameter (ports in this case). | ||
ports.forEach(function(port) { | ports.forEach(function(port) { | ||
// We still need to wait for the connected peer to notify as able to start | // We still need to wait for the connected peer to notify as able to start | ||
| Line 182: | Line 182: | ||
// In this example approach, we probably don't need a bidirectional communication | // In this example approach, we probably don't need a bidirectional communication | ||
// as we have that through a different keyword, but we can always set a message | // as we have that through a different keyword, but we can always set a message | ||
// handler via | // handler via InterAppMessagePort.onmessage at this point to handle the messages sent from | ||
// the peer on the other side of the port. | // the peer on the other side of the port. | ||
port.onmessage = myMessageHandler; | port.onmessage = myMessageHandler; | ||