{
  "classes": [
    {
      "constants": [],
      "types": [
        {
          "lua_type": "type Message = {\n    data: string,\n    binary: boolean,\n}",
          "name": "Message",
          "tags": [],
          "source": {
            "path": "",
            "line": 452
          },
          "fields": [
            {
              "lua_type": "data: string",
              "name": "data",
              "desc": ""
            },
            {
              "lua_type": "binary: boolean",
              "name": "binary",
              "desc": ""
            }
          ],
          "desc": "A message returned by [[WebSocket.receive]].\n\n@interface Message\n.data string -- The payload. For text frames this is a UTF-8 string; for binary frames it contains raw bytes.\n.binary boolean -- `true` when the message was sent as a binary frame.\n"
        },
        {
          "lua_type": "type ConnectOptions = {\n    headers: { [string]: string }?,\n    timeout: number?,\n    subprotocols: { string }?,\n    compress: boolean?,\n    heartbeat: number?,\n}",
          "name": "ConnectOptions",
          "tags": [],
          "source": {
            "path": "",
            "line": 748
          },
          "fields": [
            {
              "lua_type": "headers: { [string]: string }?",
              "name": "headers",
              "desc": ""
            },
            {
              "lua_type": "timeout: number?",
              "name": "timeout",
              "desc": ""
            },
            {
              "lua_type": "subprotocols: { string }?",
              "name": "subprotocols",
              "desc": ""
            },
            {
              "lua_type": "compress: boolean?",
              "name": "compress",
              "desc": ""
            },
            {
              "lua_type": "heartbeat: number?",
              "name": "heartbeat",
              "desc": ""
            }
          ],
          "desc": "Options for [[connect]].\n\n@interface ConnectOptions\n.headers { [string]: string }? -- Extra headers to include in the upgrade request.\n.timeout number? -- Socket timeout in seconds.\n.subprotocols { string }? -- Requested sub-protocols (`Sec-WebSocket-Protocol`).\n.compress boolean? -- When `true`, negotiates `permessage-deflate` compression (RFC 7692).\n.heartbeat number? -- Interval in seconds between automatic ping frames. `nil` or `0` disables.\n"
        },
        {
          "lua_type": "type UpgradeOptions = {\n    subprotocol: string?,\n    compress: boolean?,\n    heartbeat: number?,\n}",
          "name": "UpgradeOptions",
          "tags": [],
          "source": {
            "path": "",
            "line": 900
          },
          "fields": [
            {
              "lua_type": "subprotocol: string?",
              "name": "subprotocol",
              "desc": ""
            },
            {
              "lua_type": "compress: boolean?",
              "name": "compress",
              "desc": ""
            },
            {
              "lua_type": "heartbeat: number?",
              "name": "heartbeat",
              "desc": ""
            }
          ],
          "desc": "Options for [[upgrade]].\n\n@interface UpgradeOptions\n.subprotocol string? -- The sub-protocol to select. Sent back in `Sec-WebSocket-Protocol`.\n.compress boolean? -- When `true`, accepts `permessage-deflate` if the client offered it.\n.heartbeat number? -- Interval in seconds between automatic ping frames. `nil` or `0` disables.\n"
        }
      ],
      "name": "@eryx/websocket",
      "tags": [],
      "functions": [],
      "properties": [],
      "source": {
        "path": "",
        "line": 0
      },
      "desc": "WebSocket client and server library (RFC 6455).\n\n**Client - connect to a WebSocket server:**\n```luau\nlocal websocket = require(\"@eryx/websocket\")\n\nlocal ws = websocket.connect(\"ws://localhost:8080/chat\")\nws:send(\"hello\")\n\nlocal msg = ws:receive()\nif msg then\n\tprint(msg.data)\nend\n\nws:close()\n```\n\n**Client - secure WebSocket (wss://):**\n```luau\nlocal ws = websocket.connect(\"wss://echo.example.com/ws\")\n```\n\n**Client - with compression and heartbeat:**\n```luau\nlocal ws = websocket.connect(\"wss://echo.example.com/ws\", {\n    compress = true,       -- negotiate permessage-deflate\n    heartbeat = 30,        -- send a ping every 30 seconds\n})\n```\n\n**Server - upgrade inside an HTTP handler:**\n```luau\nlocal http = require(\"@eryx/http\")\nlocal websocket = require(\"@eryx/websocket\")\n\nlocal server = http.createServer(function(req, res)\n    if req.path == \"/ws\" then\n        local ws = websocket.upgrade(req, res, { compress = true })\n        while true do\n            local msg = ws:receive()\n            if not msg then break end\n            ws:send(\"echo: \" .. msg.data)\n        end\n        return\n    end\n    res:send(200, \"Hello!\")\nend)\nserver:listen()\n```\n\nThe server upgrade works with both HTTP and HTTPS servers - TLS is\nalready handled by the HTTP server before the request arrives, so the\nupgraded WebSocket transparently inherits the encrypted transport.\n"
    },
    {
      "is_primary_export": false,
      "source": {
        "path": "",
        "line": 413
      },
      "tags": [],
      "properties": [
        {
          "tags": [],
          "lua_type": "_sock: any",
          "name": "_sock",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_isClient: boolean",
          "name": "_isClient",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_closed: boolean",
          "name": "_closed",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_closeSent: boolean",
          "name": "_closeSent",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_closeReceived: boolean",
          "name": "_closeReceived",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_deflate: DeflateState?",
          "name": "_deflate",
          "desc": ""
        },
        {
          "tags": [],
          "lua_type": "_heartbeatThread: thread?",
          "name": "_heartbeatThread",
          "desc": ""
        }
      ],
      "desc": "A WebSocket connection.\n\nObtained from [[connect]] (client) or [[upgrade]] (server).\nProvides methods to send and receive messages, send pings, and\nperform the close handshake.\n",
      "name": "WebSocket",
      "functions": [
        {
          "source": {
            "path": "",
            "line": 415
          },
          "is_method": false,
          "signature": "WebSocket._new(sock: any, isClient: boolean, deflate: DeflateState?, heartbeatInterval: number?) → WebSocket",
          "owner": "WebSocket",
          "desc": "",
          "tags": [],
          "name": "_new",
          "return_str": "WebSocket",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "WebSocket",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "any",
              "name": "sock",
              "desc": ""
            },
            {
              "lua_type": "boolean",
              "name": "isClient",
              "desc": ""
            },
            {
              "lua_type": "DeflateState?",
              "name": "deflate",
              "desc": ""
            },
            {
              "lua_type": "number?",
              "name": "heartbeatInterval",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 468
          },
          "is_method": true,
          "signature": "WebSocket:send(\n    data: string | buffer,  -- The payload to send. Strings are sent as-is; buffers are converted with `buffer.tostring`.\n    binary: boolean?  -- When `true`, sends a binary frame (opcode 0x2) instead of a text frame (opcode 0x1). Defaults to `false`. \n) → ()",
          "owner": "WebSocket",
          "desc": "Sends a text or binary message.\n\nIf `permessage-deflate` was negotiated, the message is automatically\ncompressed before sending.\n",
          "tags": [],
          "name": "send",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "string | buffer",
              "name": "data",
              "desc": "The payload to send. Strings are sent as-is; buffers are converted with `buffer.tostring`."
            },
            {
              "lua_type": "boolean?",
              "name": "binary",
              "desc": "When `true`, sends a binary frame (opcode 0x2) instead of a text frame (opcode 0x1). Defaults to `false`. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 496
          },
          "is_method": true,
          "signature": "WebSocket:ping(\n    data: (string | buffer)?  -- Optional payload (≤ 125 bytes). \n) → ()",
          "owner": "WebSocket",
          "desc": "Sends a Ping control frame.\n",
          "tags": [],
          "name": "ping",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "(string | buffer)?",
              "name": "data",
              "desc": "Optional payload (≤ 125 bytes). "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 515
          },
          "is_method": true,
          "signature": "WebSocket:pong(\n    data: (string | buffer)?  -- Optional payload (≤ 125 bytes). Typically the same data received in the corresponding Ping. \n) → ()",
          "owner": "WebSocket",
          "desc": "Sends a Pong control frame.\n",
          "tags": [],
          "name": "pong",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "(string | buffer)?",
              "name": "data",
              "desc": "Optional payload (≤ 125 bytes). Typically the same data received in the corresponding Ping. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 539
          },
          "is_method": true,
          "signature": "WebSocket:receive() → (\n    Message?  -- The received message, or `nil` when the connection has been closed. \n)",
          "owner": "WebSocket",
          "desc": "Blocks until a complete data message arrives, or the connection closes.\n\nHandles fragmented messages, automatically responds to Ping frames\nwith Pong, and performs the close handshake when a close frame is\nreceived. If `permessage-deflate` was negotiated, compressed messages\n(RSV1 set) are automatically decompressed.\n",
          "tags": [],
          "name": "receive",
          "return_str": "Message?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "Message?",
              "desc": "The received message, or `nil` when the connection has been closed. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 626
          },
          "is_method": true,
          "signature": "WebSocket:close(\n    code: number?,  -- Optional status code (e.g. `1000` for normal closure).\n    reason: string?  -- Optional human-readable close reason. \n) → ()",
          "owner": "WebSocket",
          "desc": "Initiates the WebSocket close handshake.\n\nSends a close frame, waits for the server's close reply (if not\nalready received), then shuts down the underlying socket. Also\ncancels any active heartbeat.\n",
          "tags": [],
          "name": "close",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "number?",
              "name": "code",
              "desc": "Optional status code (e.g. `1000` for normal closure)."
            },
            {
              "lua_type": "string?",
              "name": "reason",
              "desc": "Optional human-readable close reason. "
            }
          ]
        }
      ],
      "metamethods": [],
      "types": []
    }
  ]
}