Created
February 10, 2019 23:50
-
-
Save paullj/a79b8d63502665c2af476a532ee8e369 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
import socket from './../socket'; // Doesnt work. | |
// This works though | |
// import io from 'socket.io-client' | |
// const socket = io(); | |
//... | |
function startPath(point) { | |
//... | |
} | |
function continuePath(point) { | |
//... | |
} | |
function endPath(point) { | |
//... | |
} | |
socket.on('startPath', (data) => { | |
startPath(data); | |
}); | |
socket.on('continuePath', (data) => { | |
continuePath(data) | |
}); | |
socket.on('endPath', (data) => { | |
endPath(data); | |
}); | |
//... |
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
io.on('connection', function (socket) { | |
socket.on('startPath', function(data) { | |
socket.broadcast.emit('startPath', data); | |
}); | |
socket.on('continuePath', function(data) { | |
socket.broadcast.emit('continuePath', data); | |
}); | |
socket.on('endPath', function(data) { | |
socket.broadcast.emit('endPath', data); | |
}); | |
}); |
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
import Vue from 'vue'; | |
import VueSocketIO from 'vue-socket.io'; | |
import * as io from 'socket.io-client'; | |
export const SocketInstance = io('http://localhost:3000'); | |
Vue.use(new VueSocketIO({ | |
connection: SocketInstance | |
})); | |
export default SocketInstance; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment