mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-22 00:45:15 +08:00
26e6434b75
- hippy-vue: ElementNode add repaintWithChildren API - hippy-vue: support remove outdated style of HMR chunk - hippy-vue-loader: support style hmr - hippy-vue-css-loader: support remove outdated style of HMR chunk - debug-server, vue-demo, react-demo, hippy-react: support hmr - debug-server: add hippy-dev command
28 lines
591 B
JavaScript
28 lines
591 B
JavaScript
import SockJS from '../modules/sockjs-client/index';
|
|
import { log } from '../utils/log';
|
|
|
|
export default class SockJSClient {
|
|
constructor(url) {
|
|
// SockJS requires `http` and `https` protocols
|
|
this.sock = new SockJS(url.replace(/^ws:/i, 'http:').replace(/^wss:/i, 'https:'));
|
|
this.sock.onerror = (error) => {
|
|
log.error(error);
|
|
};
|
|
}
|
|
|
|
onOpen(f) {
|
|
this.sock.onopen = f;
|
|
}
|
|
|
|
onClose(f) {
|
|
this.sock.onclose = f;
|
|
}
|
|
|
|
// call f with the message string as the first argument
|
|
onMessage(f) {
|
|
this.sock.onmessage = (e) => {
|
|
f(e.data);
|
|
};
|
|
}
|
|
}
|