Last active
July 8, 2016 13:21
-
-
Save NullVoxPopuli/81f0b9528c3ddd608737af4261f4b737 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install --save actioncable | |
import * as ActionCable from 'actioncable/lib/assets/compiled/action_cable'; | |
let myUid = '123'; | |
let url = `ws://mesh-relay-in-us-1.herokuapp.com?uid=${myUid}`; | |
const cable = ActionCable.createConsumer(url); | |
const channel = cable.subscriptions.create({ channel: 'MeshRelayChannel', }, { | |
connected: () => { | |
console.log('connected'); | |
}, | |
disconnected: (data) => { | |
console.log(data); | |
console.log('disconnected'); | |
}, | |
rejected: (data) => { | |
console.log(data); | |
console.log('rejected'); | |
}, | |
received: (data) => { | |
console.log(data); | |
console.log('received'); | |
} | |
}); | |
setTimeout(() => { | |
channel.send({ to: myUid, message: 'test message', action: 'chat' }); | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment