# sa-long-polling

> Fork of https://github.com/Reselim/roblox-long-polling for the SimpleAdmin server. All credits go to Reselim.

Latest version **1.1.5** (published 2020-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install sa-long-polling
pnpm add sa-long-polling
yarn add sa-long-polling
bun add sa-long-polling
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2020-07-26 |
| First published | 2020-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | UltraaaDev |
| Maintainers | ultradev |

## Links

- npm: https://www.npmjs.com/package/sa-long-polling
- Repository: https://github.com/SimpleAdminRbx/sa-long-polling
- Homepage: https://github.com/SimpleAdminRbx/sa-long-polling#readme
- Issues: https://github.com/SimpleAdminRbx/sa-long-polling/issues
- npm.io page: https://npm.io/package/sa-long-polling

## Dependencies (3)

- [uuid](https://npm.io/package/uuid.md) ^3.2.1
- [express](https://npm.io/package/express.md) ^4.16.2
- [body-parser](https://npm.io/package/body-parser.md) ^1.18.2

## Recent versions

- 1.1.5 (latest) — 2020-07-26
- 1.1.4 — 2020-07-25
- 1.1.3 — 2020-07-25
- 1.1.2 — 2020-07-25
- 1.1.1 — 2020-07-25
- 1.1.0 — 2020-07-25
- 1.0.3 — 2020-07-25
- 1.0.2 — 2020-07-20

## README

# sa-long-polling

Fork of https://github.com/Reselim/roblox-long-polling for the SimpleAdmin server. All credits go to Reselim.

## Example

#### Server

```js
var longPolling = require("sa-long-polling");
var server = new longPolling();

var validateApiKey = async (key) => {
	// Logic here

	return true;
}

server.on("connection", async (conn, req) => {
    console.log(`New connection (id: ${conn.id})`);

    if (conn.id == 'NOAPIKEY' || !await validateApiKey(conn.apikey)) {
        console.log(`Unauthorized connection, terminating.`)
        conn.send("unauth");
        delete conn;
        return;
    }

    conn.on("disconnect", () => {
        console.log(`${conn.id} disconnected`);
    });
});

server.listen(3000);
```

### Roblox

```lua
local Connection = require(script.Connection)
local client = Connection.new()

client:connect("0.0.0.0:3000", false, "")
-- ip:port, secure, api key

client:on("unauth", function()
    print("Server terminated connection: unauthorized");
    script.Disabled = true;
end)

client:send("ping")

client:on("pong", function()
	print("Pong!")
end)

game:BindToClose(function()
    client:disconnect()
end)
```

---
_Source: https://npm.io/package/sa-long-polling · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
