import { ActionBuilder, ChainBuilder, CheckBuilder, Duration, Session, Wrapper } from "@gatling.io/core"; import { RequestActionBuilder } from "./request"; import JvmWsFrameCheckBinary = io.gatling.javaapi.http.WsFrameCheck$Binary; import JvmWsFrameCheckText = io.gatling.javaapi.http.WsFrameCheck$Text; /** * DSL for building WebSocket configurations * *
Immutable, so all methods return a new occurrence and leave the original unmodified.
*/
export interface Ws {
/**
* Define a custom WebSocket name so multiple WebSockets for the same virtual users don't conflict
*
* @param wsName - the name, expressed as a Gatling Expression Language String
* @returns a new Ws instance
*/
wsName(wsName: string): Ws;
/**
* Define a custom WebSocket name so multiple WebSockets for the same virtual users don't conflict
*
* @param wsName - the name, expressed as a function
* @returns a new Ws instance
*/
wsName(wsName: (session: Session) => string): Ws;
/**
* Boostrap an action to connect the WebSocket
*
* @param url - the url to connect to, expressed as a Gatling Expression Language String
* @returns the next DSL step
*/
connect(url: string): WsConnectActionBuilder;
/**
* Boostrap an action to connect the WebSocket
*
* @param url - the url to connect to, expressed as a function
* @returns the next DSL step
*/
connect(url: (session: Session) => string): WsConnectActionBuilder;
/**
* Boostrap an action to send a TEXT frame
*
* @param text - the text to send, expressed as a Gatling Expression Language String
* @returns the next DSL step
*/
sendText(text: string): WsSendTextActionBuilder;
/**
* Boostrap an action to send a TEXT frame
*
* @param text - the text to send, expressed as a function
* @returns the next DSL step
*/
sendText(text: (session: Session) => string): WsSendTextActionBuilder;
/**
* Boostrap an action to send a BINARY frame
*
* @param bytes - the static bytes to send
* @returns the next DSL step
*/
sendBytes(bytes: number[]): WsSendBinaryActionBuilder;
/**
* Boostrap an action to send a BINARY frame
*
* @param bytes - the bytes to send, expressed as a Gatling Expression Language String
* @returns the next DSL step
*/
sendBytes(bytes: string): WsSendBinaryActionBuilder;
/**
* Boostrap an action to send a BINARY frame
*
* @param bytes - the bytes to send, expressed as a function
* @returns the next DSL step
*/
sendBytes(bytes: (session: Session) => number[]): WsSendBinaryActionBuilder;
/**
* Boostrap an action to send a CLOSE frame with the default 1000 status code
*
* @returns the next DSL step
*/
close(): ActionBuilder;
/**
* Boostrap an action to send a CLOSE frame with specified status and reason
*
* @param statusCode - the close frame status code
* @param reason - the close frame reason
* @returns the next DSL step
*/
close(statusCode: number, reason: string): ActionBuilder;
}
type WsProcessUnmatchedMessagesCallback = (messages: WsInboundMessage[], session: Session) => Session;
export interface WsPrefix {
/**
* Bootstrap a check on inbound TEXT frames
*
* @param name - the name of the check, expressed as a Gatling Expression Language String
* @returns the next DSL step
*/
checkTextMessage(name: string): WsFrameCheckText;
/**
* Bootstrap a check on inbound TEXT frames
*
* @param name - the name of the check, expressed as a function
* @returns the next DSL step
*/
checkTextMessage(name: (session: Session) => string): WsFrameCheckText;
/**
* Bootstrap a check on inbound BINARY frames
*
* @param name - the name of the check, expressed as a Gatling Expression Language String
* @returns the next DSL step
*/
checkBinaryMessage(name: string): WsFrameCheckBinary;
/**
* Bootstrap a check on inbound BINARY frames
*
* @param name - the name of the check, expressed as a function
* @returns the next DSL step
*/
checkBinaryMessage(name: (session: Session) => string): WsFrameCheckBinary;
/**
* Process the currently buffered inbound WebSocket messages and empty the buffer
*
* @param f - the function to process the buffered messages
* @returns an ActionBuilder
*/
processUnmatchedMessages(f: WsProcessUnmatchedMessagesCallback): ActionBuilder;
/**
* Process the currently buffered inbound WebSocket messages and empty the buffer
*
* @param wsName - the name of the WebSocket, expressed as a Gatling Expression Language String
* @param f - the function to process the buffered messages
* @returns an ActionBuilder
*/
processUnmatchedMessages(wsName: string, f: WsProcessUnmatchedMessagesCallback): ActionBuilder;
/**
* Process the currently buffered inbound WebSocket messages and empty the buffer
*
* @param wsName - the name of the WebSocket, expressed as a function
* @param f - the function to process the buffered messages
* @returns an ActionBuilder
*/
processUnmatchedMessages(wsName: (session: Session) => string, f: WsProcessUnmatchedMessagesCallback): ActionBuilder;
}
export interface WsAwaitActionBuilder Immutable, so all methods return a new occurrence and leave the original unmodified.
*/
export interface WsConnectActionBuilder extends RequestActionBuilder Immutable, so all methods return a new occurrence and leave the original unmodified.
*/
export interface WsSendTextActionBuilder extends WsAwaitActionBuilder Immutable, so all methods return a new occurrence and leave the original unmodified.
*/
export interface WsSendBinaryActionBuilder extends WsAwaitActionBuilder Immutable, so all methods return a new occurrence and leave the original unmodified.
*/
export interface WsFrameCheckBinary extends Wrapper Immutable, so all methods return a new occurrence and leave the original unmodified.
*/
export interface WsFrameCheckText extends Wrapper