There's two ways to do this:
- convert in the sender and send the conversion result to the receiver
- send the input to the receiver and convert there
Assuming you have your own convertCurrencty(amount, currency)
function, you can do this with the following:
On the sender
There is the update
function in the sender that takes the text from the input and sends it to the receiver, so you want to hook into that.
I am talking about line 180 to 182:
function update() {
var converted = convertCurrency(document.getElementById("input").value, 'USD');
sendMessage(converted);
}
In the receiver
Alternatively you can do the conversion in the receiver's message callback.
I'm referring to lines 80 to 87:
window.messageBus.onMessage = function(event) {
console.log('Message [' + event.senderId + ']: ' + event.data);
// display the message from the sender
displayText(convertCurrency(event.data, 'USD'));
// inform all senders on the CastMessageBus of the incoming message event
// sender message listener will be invoked
window.messageBus.send(event.senderId, event.data);
}
Because basically all the Chromecast code does is send a string from the sender to the receiver and the receiver displays it. So all you need to do is modify the string either before or after it's sent :)