1.1.5 • Published 4 years ago

sa-long-polling v1.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

sa-long-polling

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

Example

Server

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

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)
1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago