http/https与websocket的ws/wss的关系
1.对应关系
http -> new WebSocket('ws://xxx') https -> new WebSocket('wss://xxx')
2.兼容解决方案
var protocol = location.protocol === 'https:' ? 'wss://localhost:8888' : 'ws://localhost:8889'; new WebSocket(protocol);
1.对应关系
http -> new WebSocket('ws://xxx') https -> new WebSocket('wss://xxx')
2.兼容解决方案
var protocol = location.protocol === 'https:' ? 'wss://localhost:8888' : 'ws://localhost:8889'; new WebSocket(protocol);