You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
501 B
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

let socket = io();
socket.on('connect', () => {
let persistToken = localStorage.getItem('playerToken')
if (persistToken) {
socket.emit('token:set', persistToken);
} else {
socket.emit('token:refresh');
}
});
socket.on('token:expired', () => { // token已过期重载整个播放器
socket.emit('token:refresh');
});
socket.on('token:update', (token) => { // 收到token
console.log('new token: ', token);
localStorage.setItem('playerToken', token)
});