I currently have this line in a javascript function that posts a message to channel 1 with realtime.co
xRTML.ConnectionManager.sendMessage({connections: ['myConnection'], channel: '1',
content:xrtmlMessage});
This works fine.
My problem is using a variable, let’s say ‘x’, instead of explicitly stating – channel: ‘1’.
Essentially I want to be able to post to different channels by writing – … channel: x, …
But writing this gives the error:
Uncaught TypeError: Object 1 has no method ‘indexOf’
‘x’ is already declared as x=1;
So I tried declaring y=’1′; (with single marks instead of none) and writing channel: y – and this works. So I tried building this as a string (mark 1 mark)
y = "'" + x + "'";
This gives the error that the channel has invalid characters, so no double quotation marks or escaping the single mark with a backslash either, tried that. I also tried parseInt(x); to ensure x was an integer, to no avail.
Has anyone got any other suggestions or even tried doing the same thing with xRTML?
Thanks in advance
Have you tried toString()?