2019-07-13 18:16:46 +00:00
|
|
|
import {Socket} from "phoenix"
|
|
|
|
|
|
|
|
let socket = new Socket("/socket", {params: {token: window.userToken}})
|
|
|
|
|
|
|
|
socket.connect()
|
|
|
|
|
2019-07-30 22:20:09 +00:00
|
|
|
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) })
|
|
|
|
|
2019-07-30 22:20:09 +00:00
|
|
|
let progressBar = document.getElementById("morse-progress")
|
|
|
|
|
|
|
|
channel.on("update", (content) => {
|
|
|
|
progressBar.value = content["value"]
|
2019-07-31 12:24:51 +00:00
|
|
|
progressBar.innerHTML = content["value"]
|
2019-07-30 22:20:09 +00:00
|
|
|
});
|
|
|
|
|
2019-07-13 18:16:46 +00:00
|
|
|
export default socket
|