esrom/ui/assets/js/socket.js

20 lines
536 B
JavaScript
Raw Normal View History

2019-07-13 18:16:46 +00:00
import {Socket} from "phoenix"
let socket = new Socket("/socket", {params: {token: window.userToken}})
socket.connect()
let channel = socket.channel("morse:progress", {})
2019-07-13 18:16:46 +00:00
channel.join()
.receive("ok", resp => { console.log("Joined successfully", resp) })
.receive("error", resp => { console.log("Unable to join", resp) })
let progressBar = document.getElementById("morse-progress")
channel.on("update", (content) => {
progressBar.value = content["value"]
progressBar.innerHTML = content["value"]
});
2019-07-13 18:16:46 +00:00
export default socket