Skip to content

websocket connection error #2985

@LinboLen

Description

@LinboLen
Image Image
 try {
        this.ws = TauriWebSocket.connect(this.addr);
        (this.ws as Promise<TauriWebSocket>).then((ws) => {
          setTimeout(() => {
            if (this._onOpen) {
              alert("opened")
              this._onOpen();
            }
          }, 500);

         const unListener= ws.addListener((message) => {
            alert(
              `message type: ${message.type} content: ${message.data} ${message}`
            );
            if (message.type === 'Close') {
              if (this._onClose) {
                this._onClose(message.data as CloseEvent);
                unListener()
              }
            }
          });
        });
      } catch (e: any) {
        alert('exception:' + e.message);
        if (this._onClose) {
          this._onClose();
        }
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions