Quark #

Modules #

Quark v1.4.0 Documentation

Contents

quark/ws #

Enum: PacketType #

PacketType #

Defines the types of packets used in WSClient communication.

Interface: Packet #

Packet #

Represents a packet structure used in WSClient communication.

Class: WSConversation #

WSConversation #

WSConversation is extended from WebSocket to provide a WSClient connection.

Extends: WebSocket

wsconversation.token #

Session token

readonly token: 

wsconversation.autoReconnect #

autoReconnect: 

wsconversation.connect() #

connect(): void
  • @override
    Connect to the WebSocket server.

wsconversation.close() #

close()
  • @override
    Close the conversation connection.

wsconversation.sendPacket(p) #

Send a packet to the server.

sendPacket(data: any, p: Packet): Promise<void>

Parameters:

  • data — Packet data to send

Class: WSCEvent #

WSCEvent #

Extends: Event<WSClient>

wscevent.remoteSender #

readonly remoteSender: string

wscevent.constructor(data?,sender?) #

constructor(data?: any, sender?: string)

Parameters:

  • data? — Event data
  • sender? — Remote sender id

Class: WSClient #

WSClient #

WSClient is Qktool's WebSocket service client.

Through it, you can call the service methods of server provided or listen to the service events.

Extends: Notification<WSCEvent>

wsclient.name #

Service name on the server

readonly name: string

wsclient.conv #

Conversation instance

readonly conv: WSConversation

wsclient.onLoad #

Triggered when the client is loaded and ready to use.

wsclient.constructor(serviceName,conv) #

constructor(serviceName: string, conv: WSConversation)

Parameters:

  • serviceName — Service name on the server
  • conv — Conversation instance

wsclient.receiveMessage(packet) #

To handle received messages from the server.

receiveMessage(packet: Packet): Promise<void>

wsclient.callMethod(method,data,sender) #

The remote service calls a method on the client by the method name.

callMethod(method: string, data: any, sender: string)
  • @param method: Method name to call
  • @param data?: Data to send
  • @param timeout?: Timeout in milliseconds, default 120s
  • @param sender?: Sender name, default this service name

wsclient.send(method,data?,sender?) #

To call a method on the server but there will be no callback.

send(method: string, data?: any, sender?: string)

Parameters:

  • method — Method name to call
  • data? — Data to send
  • sender? — Sender name, default this service name