Closed bigperson closed 7 years ago
+1
@bigperson @terion-name Have you guys included the socket io library somewhere? the same setup is required as laravel echo.
If you did it might be better to register VueEcho with a configured laravel echo instance
@happyDemon yeh, I've already figured it out, just forgot to comment.
<script src="//{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>
One big problem with this, that if socket-server is down by some reason, this breaks the entire app. I think that this needs to be inserted dynamically with error handling, a theme to think about
@terion-name This is something you might better report at laravel-echo, since this is just a wrapper around that lib.
The general assumption from laravel-echo is that the socket io library gets imported, so it will always be available.
@happyDemon this snippet:
<script src="//{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>
is from echo docs. if I just import IO via webpack and attach it to window — everything should work?
@terion-name I didn't know that they put that in the echo docs (I've only been using the pusher driver) :/
surely it's best to have all the code on the same server in case of hiccups on the socket server's side.
The socket IO client has its own package:
npm install socket.io-client --save
const io = window.io = require('socket.io-client');
// Or ES6
import * as io from 'socket.io-client';
window.io = io;
right ,it must add const io = window.io = require('socket.io-client'); cdn way not work
I get an Error like this main.js:1 Uncaught ReferenceError: io is not defined at main.js:1 anynone please help me.....
@hacker248 you have to include the library, seems like the browser can't find a reference to it.
Error: Uncaught ReferenceError: io is not defined