add connection status log, move to arrow functions
This commit is contained in:
Vendored
+14
-12
@@ -257,30 +257,32 @@
|
|||||||
get isConnected() {
|
get isConnected() {
|
||||||
return this.udn.ws != void 0 && this.udn.ws.readyState == 1;
|
return this.udn.ws != void 0 && this.udn.ws.readyState == 1;
|
||||||
}
|
}
|
||||||
get url() {
|
get address() {
|
||||||
return this.udn.ws?.url;
|
return this.udn.ws?.url;
|
||||||
}
|
}
|
||||||
// connection
|
// connection
|
||||||
connect(address2) {
|
connect = (address2) => {
|
||||||
this.udn.connect(address2);
|
this.udn.connect(address2);
|
||||||
}
|
};
|
||||||
disconnect() {
|
disconnect = () => {
|
||||||
this.udn.disconnect();
|
this.udn.disconnect();
|
||||||
}
|
};
|
||||||
handleDisconnect() {
|
handleConnectionChange = () => {
|
||||||
}
|
console.log("connection status:", this.isConnected, this.address);
|
||||||
|
};
|
||||||
// messaging
|
// messaging
|
||||||
sendChatMessage(chatMessage) {
|
sendChatMessage = (chatMessage) => {
|
||||||
const stringifiedBody = stringify(chatMessage);
|
const stringifiedBody = stringify(chatMessage);
|
||||||
return this.udn.sendMessage(chatMessage.channel, stringifiedBody);
|
return this.udn.sendMessage(chatMessage.channel, stringifiedBody);
|
||||||
}
|
};
|
||||||
handleMessage(data) {
|
handleMessage = (data) => {
|
||||||
}
|
};
|
||||||
// setup
|
// setup
|
||||||
constructor() {
|
constructor() {
|
||||||
this.udn = new UDNFrontend();
|
this.udn = new UDNFrontend();
|
||||||
this.udn.onmessage = this.handleMessage;
|
this.udn.onmessage = this.handleMessage;
|
||||||
this.udn.ondisconnect = this.handleDisconnect;
|
this.udn.onconnect = this.handleConnectionChange;
|
||||||
|
this.udn.ondisconnect = this.handleConnectionChange;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,33 +14,36 @@ export default class ConnectionModel {
|
|||||||
return this.udn.ws != undefined && this.udn.ws.readyState == 1;
|
return this.udn.ws != undefined && this.udn.ws.readyState == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
get url(): string | undefined {
|
get address(): string | undefined {
|
||||||
return this.udn.ws?.url;
|
return this.udn.ws?.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// connection
|
// connection
|
||||||
connect(address: string): void {
|
connect = (address: string): void => {
|
||||||
this.udn.connect(address);
|
this.udn.connect(address);
|
||||||
}
|
};
|
||||||
|
|
||||||
disconnect(): void {
|
disconnect = (): void => {
|
||||||
this.udn.disconnect();
|
this.udn.disconnect();
|
||||||
}
|
};
|
||||||
|
|
||||||
handleDisconnect() {}
|
handleConnectionChange = () => {
|
||||||
|
console.log("connection status:", this.isConnected, this.address);
|
||||||
|
};
|
||||||
|
|
||||||
// messaging
|
// messaging
|
||||||
sendChatMessage(chatMessage: ChatMessage): boolean {
|
sendChatMessage = (chatMessage: ChatMessage): boolean => {
|
||||||
const stringifiedBody = stringify(chatMessage);
|
const stringifiedBody = stringify(chatMessage);
|
||||||
return this.udn.sendMessage(chatMessage.channel, stringifiedBody);
|
return this.udn.sendMessage(chatMessage.channel, stringifiedBody);
|
||||||
}
|
};
|
||||||
|
|
||||||
handleMessage(data: Message) {}
|
handleMessage = (data: Message) => {};
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
constructor() {
|
constructor() {
|
||||||
this.udn = new UDNFrontend();
|
this.udn = new UDNFrontend();
|
||||||
this.udn.onmessage = this.handleMessage;
|
this.udn.onmessage = this.handleMessage;
|
||||||
this.udn.ondisconnect = this.handleDisconnect;
|
this.udn.onconnect = this.handleConnectionChange;
|
||||||
|
this.udn.ondisconnect = this.handleConnectionChange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user