Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

ClientCloseCallback

ClientCloseCallback: (conn: MgConnection) => void

Type declaration

    • Callback method for when the connection is closed.

      Parameters

      Returns void

ClientDataReceivedCallback

ClientDataReceivedCallback: (conn: MgConnection, opcode: WebSocketOpCode, fin: boolean, data: string, bits: number) => boolean

Type declaration

    • Callback method for when a data frame has been received from the server.

      Parameters

      • conn: MgConnection

        the connection information

      • opcode: WebSocketOpCode

        websocket opcode (decoded from bits)

      • fin: boolean

        indicates that this is the final fragment in a message. The first fragment MAY also be the final fragment. (decoded from bits)

      • data: string

        payload, with mask (if any) already applied.

      • bits: number

        first byte of the websocket frame, see websocket RFC at http://tools.ietf.org/html/rfc6455, section 5.2

      Returns boolean

      true to keep socket open, false to close it

EHTTPRequest

EHTTPRequest: "GET" | "PUT" | "POST" | "HEAD" | "DELETE"

Functions

connectWebsocketClient

  • Connect to a websocket server as a client

    throws

    {MgError}

    Parameters

    • host: string

      host to connect to, i.e. "echo.websocket.org" or "192.168.1.1" or "localhost"

    • port: number

      server port

    • useSSL: boolean

      make a secure connection to server

    • path: string

      server path you are trying to connect to, i.e. if connection to localhost/app, path should be "/app"

    • cbDataReceived: ClientDataReceivedCallback

      callback to call when data is received from the server

    • Optional cbClose: ClientCloseCallback

      callback to call on connection close

    • Optional origin: string

      value of the Origin HTTP header

    Returns MgConnection | never

    New connection object

connectWebsocketClientURL

  • Connect to a websocket server as a client

    throws

    {MgError}

    Parameters

    • url: string

      URL to connect - <ws|wss>://server.domain[:port]/path

    • cbDataReceived: ClientDataReceivedCallback

      callback to call when data is received from the server

    • Optional cbClose: ClientCloseCallback

      callback to call on connection close

    • Optional origin: string

      value of the Origin HTTP header

    Returns MgConnection | never

    New connection object

getParam

  • getParam(data: string, name: string, occurence?: number): string | null
  • Returns a query parameter contained in the supplied buffer. The occurrence value is a zero-based index of a particular key name. This should not be confused with the index over all of the keys.

    Parameters

    • data: string

      the query string (text)

    • name: string

      the key to search for

    • Optional occurence: number

    Returns string | null

    parameter value or undefined

getServer

  • Get existing webserver by name

    Parameters

    • Optional name: string

      Webserver identification name, undefined = default server

    Returns CivetServer | null

    webserver object if exists, null otherwise

urlDecode

  • urlDecode(src: string, isFormUrlEncoded?: boolean): string
  • Parameters

    • src: string

      string to be decoded

    • Optional isFormUrlEncoded: boolean

    Returns string

    decoded string

urlEncode

  • urlEncode(src: string): string
  • Parameters

    • src: string

      buffer to be encoded

    Returns string

    encoded string

Generated using TypeDoc