MCPcopy Create free account
hub / github.com/duxianwei520/react / constructor

Method constructor

app/configs/socket.js:7–29  ·  view source on GitHub ↗
(ua = 'control', disable = false)

Source from the content-addressed store, hash-verified

5
6class Socket {
7 constructor(ua = 'control', disable = false) {
8 this.uid = this.random();
9 // this.group = parsed.group || 'prod';
10 this.disable = disable;
11 this.socket = io('http://47.102.198.102:8080/', {
12 transports: ['websocket'],
13 query: {
14 ua,
15 group: 'prod',
16 },
17 });
18 this.isSpeaker = false;
19 this.speakerHandlers = [];
20
21 this.socket.on('room', ({ speaker }) => {
22 this.isSpeaker = speaker === this.socket.id;
23 this.speakerHandlers.forEach((cb) => {
24 if (typeof cb === 'function') {
25 cb(this.isSpeaker);
26 }
27 });
28 });
29 }
30
31 random = () => Date.now() + Math.random();
32

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected