mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
socket.io: Factor out client connection logic
This commit is contained in:
parent
7eb0f996c3
commit
303964c51e
8 changed files with 44 additions and 38 deletions
|
@ -29,6 +29,7 @@ require('./jquery');
|
|||
const Cookies = require('./pad_utils').Cookies;
|
||||
const randomString = require('./pad_utils').randomString;
|
||||
const hooks = require('./pluginfw/hooks');
|
||||
const socketio = require('./socketio');
|
||||
|
||||
let token, padId, exportLinks, socket, changesetLoader, BroadcastSlider;
|
||||
|
||||
|
@ -51,14 +52,7 @@ const init = () => {
|
|||
Cookies.set('token', token, {expires: 60});
|
||||
}
|
||||
|
||||
const loc = document.location;
|
||||
// get the correct port
|
||||
const port = loc.port === '' ? (loc.protocol === 'https:' ? 443 : 80) : loc.port;
|
||||
// create the url
|
||||
const url = `${loc.protocol}//${loc.hostname}:${port}/`;
|
||||
|
||||
// build up the socket io connection
|
||||
socket = io.connect(url, {path: `${exports.baseURL}socket.io`});
|
||||
socket = socketio.connect(exports.baseURL);
|
||||
|
||||
// send the ready message once we're connected
|
||||
socket.on('connect', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue