add connection status log, move to arrow functions
This commit is contained in:
Vendored
+14
-12
@@ -257,30 +257,32 @@
|
||||
get isConnected() {
|
||||
return this.udn.ws != void 0 && this.udn.ws.readyState == 1;
|
||||
}
|
||||
get url() {
|
||||
get address() {
|
||||
return this.udn.ws?.url;
|
||||
}
|
||||
// connection
|
||||
connect(address2) {
|
||||
connect = (address2) => {
|
||||
this.udn.connect(address2);
|
||||
}
|
||||
disconnect() {
|
||||
};
|
||||
disconnect = () => {
|
||||
this.udn.disconnect();
|
||||
}
|
||||
handleDisconnect() {
|
||||
}
|
||||
};
|
||||
handleConnectionChange = () => {
|
||||
console.log("connection status:", this.isConnected, this.address);
|
||||
};
|
||||
// messaging
|
||||
sendChatMessage(chatMessage) {
|
||||
sendChatMessage = (chatMessage) => {
|
||||
const stringifiedBody = stringify(chatMessage);
|
||||
return this.udn.sendMessage(chatMessage.channel, stringifiedBody);
|
||||
}
|
||||
handleMessage(data) {
|
||||
}
|
||||
};
|
||||
handleMessage = (data) => {
|
||||
};
|
||||
// setup
|
||||
constructor() {
|
||||
this.udn = new UDNFrontend();
|
||||
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;
|
||||
}
|
||||
|
||||
get url(): string | undefined {
|
||||
get address(): string | undefined {
|
||||
return this.udn.ws?.url;
|
||||
}
|
||||
|
||||
// connection
|
||||
connect(address: string): void {
|
||||
connect = (address: string): void => {
|
||||
this.udn.connect(address);
|
||||
}
|
||||
};
|
||||
|
||||
disconnect(): void {
|
||||
disconnect = (): void => {
|
||||
this.udn.disconnect();
|
||||
}
|
||||
};
|
||||
|
||||
handleDisconnect() {}
|
||||
handleConnectionChange = () => {
|
||||
console.log("connection status:", this.isConnected, this.address);
|
||||
};
|
||||
|
||||
// messaging
|
||||
sendChatMessage(chatMessage: ChatMessage): boolean {
|
||||
sendChatMessage = (chatMessage: ChatMessage): boolean => {
|
||||
const stringifiedBody = stringify(chatMessage);
|
||||
return this.udn.sendMessage(chatMessage.channel, stringifiedBody);
|
||||
}
|
||||
};
|
||||
|
||||
handleMessage(data: Message) {}
|
||||
handleMessage = (data: Message) => {};
|
||||
|
||||
// setup
|
||||
constructor() {
|
||||
this.udn = new UDNFrontend();
|
||||
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