Websocket

abstract

@vitejs/vitejs-ws

Constructor

  • Constructor params:

    • url : string Connection url Default: 'ws://localhost:31420'
    • timeout : number Timeout(ms) Default: 60000
    • Object
  • Example:


import wsProvider from "@vite/vitejs-ws";
const myWs = new wsProvider("ws://localhost:8080");

WS Provider instance

Instance Properties

Name Type Description
url string Network connection path
protocol string Protocol
headers object Request header information
clientConfig object Same as Above

Instance Methods

Except for the public methods of provider instance

Reconnect

Network reconnection

disconnect

Disconnection

subscribe

Subscribe push events from server side

  • params:

    • callback : Function The result will return to this event when server side has any push event

unSubscribe

Unsubscribe