Class WispSocketInternal

The primary interface to the Websocket API

Constructors

Properties

api: WispAPI
consoleCallbacks: ((message) => void)[]

Type declaration

    • (message): void
    • Parameters

      • message: string

      Returns void

detailsPreprocessor: undefined | WebsocketDetailsPreprocessor
ghToken: undefined | string
logger: any
pool: WebsocketPool
token: undefined | string
url: undefined | string

Methods

  • Adds a new callback that will run any time a console message is rececived

    Parameters

    • callback: ((message) => void)

      The callback to run, takes a single param, message, a string

        • (message): void
        • Parameters

          • message: string

          Returns void

    Returns void

  • Internal

    Creates a new Websocket Pool

    Returns void

    Throws

    Throws an error if the URL or token are not set yet

  • Internal

    Disconnects from the websocket

    Returns Promise<void>

  • Searches all file contents for the given query

    Parameters

    • query: string

      The query string to search for

    • timeout: number = 10000

      How long to wait (in ms) for results before timing out

    Returns Promise<FilesearchResults>

  • Clones a new Repo to the given directory

    Parameters

    • url: string

      The HTTPS URL of the repository

    • dir: string

      The full path of the directory to clone the repository to

    • branch: string

      The branch of the repository to clone

    • timeout: number = 20000

      In milliseconds, how long to wait before timing out

    Returns Promise<any>

  • Performs a git pull operation on the given directory

    Parameters

    • dir: string

      The full directory path to perform a pull on

    • useAuth: boolean = false
    • timeout: number = 10000

      In milliseconds, how long to wait before timing out

    Returns Promise<any>

  • Removes a previously added console message callback

    Parameters

    • callback: ((message) => void)

      The callback function that was previously added

        • (message): void
        • Parameters

          • message: string

          Returns void

    Returns void

  • Sends a command to the server and then waits until output with the given prefix is seen in a console message

    Parameters

    • nonce: string

      The short, unique string that your output will be prefixed with

    • command: string

      The full command string to send

    • timeout: number = 1000

      In milliseconds, how long to wait for output before timing out

    Returns Promise<any>

    Example

    Runs a custom lua command that will prefix its output with our nonce, then prints the output from that command

    -- lua/autorun/server/nonce_example.lua
    concommand.Add( "myCommand", function( ply, _, args )
    if IsValid( ply ) then return end

    local nonce = args[1]
    print( nonce .. "Command output" )
    end )
    const nonce = "abc123";
    const command = `myCommand "${nonce}"`;
    try {
    const output = await wisp.socket.sendCommandNonce(nonce, command);
    console.log("Output from command:", output);
    catch (error) {
    console.error(error);
    }

    Remarks

    ℹ️ This is useful if you run code on your Server that will print output with the same prefix, letting you run commands and also receive output for it

  • Internal

    Requests and saves the Websocket details from the API

    Returns Promise<void>

  • Sets a callback to run on the Websocket Info before saving the details.

    Parameters

    Returns void

    Example

    // Change the URL of the Websocket
    wisp.socket.setWebsocketDetailsPreprocessor((info) => {
    info.url = "wss://newurl.com"
    })

    Remarks

    ℹ️ This can be used to modify the URL or token after its retrieved from the API

  • Internal

    Sets up the console listener worker

    Returns void

  • Internal

    Verifies that the pool is created and ready to use

    Returns Promise<void>

Generated using TypeDoc