rbxwebhook.js is a fork and maintained version of @Reselim and her roblox-long-polling npm module. It allows you to communicate using events similar to BindableEvents. You are able to send events to your server and receive events. You also have the capabilities to send out events to all servers similar to MessagingService
How does it work?
This uses a long-polling (better explained by @Seranok in his blog post). It basically sends a request to your server and waits for a response instead of sending back a response immediately. It will send a request and wait 60 seconds for a response, if it does not get one within that time-frame it will abort the request and send another request right after it and do the exact same thing.
What are the Pros and Cons?
Pros
Client and Server communication
Simplistic
Built into express to easily import to an already existing project.
Cons
High in HTTP request budget
Not great error handling
What is planned?
We have a few things planned in the future to ensure security and speed.
Allow for @grilme99’s rocheck to be built right into the connection. (read more about it here)
Better error handling.
Drawbacks for rocheck
You need to create an maintain the account cookie to check
There will not be any cookie refreshing (you will need to do that yourself, more about it here)
Your place needs to be multiplayer (meaning more than 1 player able to join).
Example
View Example
Server
Main Script
// MainScript
var express = require("express")
var app = express();
app.use('/rbxwebhook', require(../PATH/TO/ROUTER/FILE))
app.get('/', (req, res) => {
res.send("Howdy")
});
app.listen(3000);
I’ve released version 0.8.0 of the npm module. There are a few changes that you need to understand with this update.
NOTICE
Version 0.8.0 has changed the client.lua file meaning that you will need to change the module that you’re using for connecting to the API.
What’s new?
Added API keys for added protection.
Changed the module to fit the new API needed.
How does the protection work?
When you connect using the :connect() function in the module it will send an api request including your API key in the header. If it is correct it will successfully authenticate the request a return a unique uuid key that the module will use to authenticate requests without the apiKey.
How do I use it?
It’s very simple to add your apiKey to your project
Example
Server
Change this
const rbxwebhook = require("rbxwebhook.js");
const server = new rbxwebhook();
to this
const rbxwebhook = require("rbxwebhook.js");
const server = new rbxwebhook({apiKey: "YOURKEYHERE"});
Client
Change this
local rbxwebhook = require(game:GetService("ServerScriptService"):WaitForChild("rbxwebhook"));
local client = rbxwebhook.new();
to this
local rbxwebhook = require(game:GetService("ServerScriptService"):WaitForChild("rbxwebhook"));
local client = rbxwebhook.new( { apiKey = "YOURKEYHERE" } );
I have noticed that there are debugging console.logs still in the server.js code. I will be fixing that up in version 0.8.1 which should come out very soon. Sorry for that problem.
Update
A fix has been made and is currently being tested for stability for publishing, we don’t suggest using the current version until 0.8.1 is released.
Stability testing has concluded and version 0.8.1 is being pushed.
You don’t need to update to 0.8.1 if you don’t want to as nothing besides the console.log was removed but you should update your client.lua code for more stability in error handling.
This is quite interesting and amazing. I’ve been looking at an easier way to make actions from Discord to ROBLOX and I’ve struggled, one of the things I wanted to do is be able to kick people and ban from Discord, thanks so much for this.
There are two separate modules, there’s the npm module which is used for your Node.JS server and then the client module Which is what you place in a module script. There is no exact place where you need to put that module because it’s all up to how you want to develop but, considering it uses HTTPService and the Client doesn’t have access to that service I would suggest putting it in ServerScriptService.