Quark #

Modules #

Quark v1.3.0 Documentation


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.

wsconversation.token #

Session token

  • @get token:

wsconversation.autoReconnect #

  • autoReconnect:

wsconversation.connect() #

  • @override
    Connect to the WebSocket server.
  • @return void

wsconversation.close() #

  • @override
    Close the conversation connection.

wsconversation.sendPacket(p) #

Send a packet to the server.

METHOD_CALL_TIMEOUT #

120s

  • @const METHOD_CALL_TIMEOUT:

Class: WSCEvent #

WSCEvent #

wscevent.remoteSender #

wscevent.constructor(data?,sender?) #

  • @param data?: any Event data
  • @param sender?: string 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.

wsclient.name #

Service name on the server

wsclient.conv #

Conversation instance

wsclient.onLoad #

Triggered when the client is loaded and ready to use.

wsclient.constructor(serviceName,conv) #

  • @param serviceName: string Service name on the server
  • @param conv: WSConversation Conversation instance

wsclient.receiveMessage(packet) #

To handle received messages from the server.

wsclient.callMethod(method,data,sender) #

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

  • @param method: string
  • @param data: any
  • @param 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.

  • @param method: string Method name to call
  • @param data?: any Data to send
  • @param sender?: string Sender name, default this service name