Skip to content

Commit

Permalink
Update LuaBundle to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Holmes committed Aug 10, 2019
1 parent 5eb7d0f commit 7f47f71
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 55 deletions.
8 changes: 4 additions & 4 deletions lualib/ClientEvent.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
Expand Down Expand Up @@ -27,14 +27,14 @@ do
end;
return NetClientEvent.new(name);
end);
function NetClientEvent:getInstance()
function NetClientEvent:GetInstance()
return self.instance;
end;
function NetClientEvent:getEvent()
function NetClientEvent:GetEvent()
return self.instance.OnClientEvent;
end;
function NetClientEvent:Connect(callback)
return self:getEvent():Connect(callback);
return self:GetEvent():Connect(callback);
end;
function NetClientEvent:SendToServer(...)
local args = { ... };
Expand Down
22 changes: 12 additions & 10 deletions lualib/ClientFunction.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
Expand All @@ -19,6 +19,14 @@ do
function NetClientFunction:constructor(name)
self.lastPing = -1;
self.cached = {};
self.getCache = function()
warn(self.instance.Name .. "::getCache is deprecated, use " .. self.instance.Name .. "::GetCache instead!");
return self:GetCache();
end;
self.getInstance = function()
warn(self.instance.Name .. "::getInstance is deprecated, use " .. self.instance.Name .. "::GetInstance instead!");
return self:GetInstance();
end;
self.instance = getRemoteOrThrow("RemoteFunction", name);
assert(IS_CLIENT, "Cannot create a Net.ClientFunction on the Server!");
assert(functionExists(name), "The specified function '" .. name .. "' does not exist!");
Expand All @@ -30,16 +38,10 @@ do
end;
return NetClientFunction.new(name);
end);
function NetClientFunction:getCallback()
return self.instance.OnClientInvoke;
end;
function NetClientFunction:setCallback(func)
self.instance.OnClientInvoke = func;
end;
function NetClientFunction:getInstance()
function NetClientFunction:GetInstance()
return self.instance;
end;
function NetClientFunction:getCache()
function NetClientFunction:GetCache()
local cache = self.instance:FindFirstChild("Cache");
if cache then
return cache.Value;
Expand All @@ -49,7 +51,7 @@ do
end;
function NetClientFunction:CallServer(...)
local args = { ... };
if self.lastPing < os.time() + self:getCache() then
if self.lastPing < os.time() + self:GetCache() then
local result = self.instance:InvokeServer(unpack(args));
self.cached = result;
self.lastPing = os.time();
Expand Down
2 changes: 1 addition & 1 deletion lualib/GlobalClientEvent.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
Expand Down
2 changes: 1 addition & 1 deletion lualib/GlobalEvent.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
Expand Down
2 changes: 1 addition & 1 deletion lualib/GlobalServerEvent.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
Expand Down
62 changes: 50 additions & 12 deletions lualib/ServerEvent.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
local NetServerEvent;
local _0 = TS.import(script.Parent, "internal");
local findOrCreateRemote, IS_CLIENT = _0.findOrCreateRemote, _0.IS_CLIENT;
local findOrCreateRemote, IS_CLIENT, t_assert = _0.findOrCreateRemote, _0.IS_CLIENT, _0.t_assert;
local Players = game:GetService("Players");
local NetServerEvent;
do
NetServerEvent = setmetatable({}, {
__tostring = function() return "NetServerEvent" end;
Expand All @@ -17,52 +17,90 @@ do
self:constructor(...);
return self;
end;
function NetServerEvent:constructor(name)
function NetServerEvent:constructor(name, ...)
local recievedPropTypes = { ... };
self.instance = findOrCreateRemote("RemoteEvent", name);
assert(not IS_CLIENT, "Cannot create a Net.ServerEvent on the Client!");
if #recievedPropTypes > 0 then
self.propTypes = recievedPropTypes;
end;
end;
function NetServerEvent:WithStrictCall(...)
local callPropTypes = { ... };
self.callTypes = callPropTypes;
return self;
end;
function NetServerEvent:getInstance()
function NetServerEvent:GetInstance()
return self.instance;
end;
function NetServerEvent:getEvent()
function NetServerEvent:GetEvent()
return self.instance.OnServerEvent;
end;
function NetServerEvent:Connect(callback)
return self:getEvent():Connect(callback);
if self.propTypes ~= nil then
return self:GetEvent():Connect(function(sourcePlayer, ...)
local args = { ... };
if t_assert(self.propTypes, args) then
callback(sourcePlayer, unpack(args));
end;
end);
else
return self:GetEvent():Connect(callback);
end;
end;
function NetServerEvent:SendToAllPlayers(...)
local args = { ... };
self.instance:FireAllClients(unpack(args));
if self.callTypes ~= nil then
if not t_assert(self.callTypes, args) then
return nil;
end;
end;
self.instance:FireAllClients(unpack((args)));
end;
function NetServerEvent:SendToAllPlayersExcept(blacklist, ...)
local args = { ... };
if self.callTypes ~= nil then
if not t_assert(self.callTypes, args) then
return nil;
end;
end;
if (typeof(blacklist) == "Instance") then
local otherPlayers = TS.array_filter(Players:GetPlayers(), function(p)
return p ~= blacklist;
end);
for _1 = 1, #otherPlayers do
local player = otherPlayers[_1];
self.instance:FireClient(player, unpack(args));
self.instance:FireClient(player, unpack((args)));
end;
elseif (typeof(blacklist) == "table") then
local _1 = Players:GetPlayers();
for _2 = 1, #_1 do
local player = _1[_2];
if TS.array_indexOf(blacklist, player) == -1 then
self.instance:FireClient(player, unpack(args));
self.instance:FireClient(player, unpack((args)));
end;
end;
end;
end;
function NetServerEvent:SendToPlayer(player, ...)
local args = { ... };
self.instance:FireClient(player, unpack(args));
if self.callTypes ~= nil then
if not t_assert(self.callTypes, args) then
return nil;
end;
end;
self.instance:FireClient(player, unpack((args)));
end;
function NetServerEvent:SendToPlayers(players, ...)
local args = { ... };
if self.callTypes ~= nil then
if not t_assert(self.callTypes, args) then
return nil;
end;
end;
for _1 = 1, #players do
local player = players[_1];
self:SendToPlayer(player, unpack(args));
self:SendToPlayer(player, unpack((args)));
end;
end;
end;
Expand Down
60 changes: 46 additions & 14 deletions lualib/ServerFunction.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
local _0 = TS.import(script.Parent, "internal");
local findOrCreateRemote, IS_CLIENT = _0.findOrCreateRemote, _0.IS_CLIENT;
local findOrCreateRemote, IS_CLIENT, t_assert = _0.findOrCreateRemote, _0.IS_CLIENT, _0.t_assert;
local function t_string(value)
return true;
end;
local NetServerFunction;
do
NetServerFunction = setmetatable({}, {
Expand All @@ -16,29 +19,63 @@ do
self:constructor(...);
return self;
end;
function NetServerFunction:constructor(name)
function NetServerFunction:constructor(name, ...)
local recievedPropTypes = { ... };
self.getCallback = function()
warn(self.instance.Name .. "::getCallback is deprecated, use " .. self.instance.Name .. "::GetCallback instead!");
return self:GetCallback();
end;
self.getClientCache = function()
warn(self.instance.Name .. "::getClientCache is deprecated, use " .. self.instance.Name .. "::GetClientCache instead!");
return self:GetClientCache();
end;
self.setCallback = function(func)
warn(self.instance.Name .. "::setCallback is deprecated, use " .. self.instance.Name .. "::SetCallback instead!");
return self:SetCallback(func);
end;
self.setClientCache = function(timeout)
warn(self.instance.Name .. "::setClientCache is deprecated, use " .. self.instance.Name .. "::SetClientCache instead!");
return self:SetClientCache(timeout);
end;
self.instance = findOrCreateRemote("RemoteFunction", name);
assert(not IS_CLIENT, "Cannot create a Net.ServerFunction on the Client!");
if #recievedPropTypes > 0 then
self.propTypes = recievedPropTypes;
end;
end;
function NetServerFunction:getCallback()
function NetServerFunction:GetCallback()
return self.instance.OnServerInvoke;
end;
function NetServerFunction:setCallback(func)
self.instance.OnServerInvoke = func;
function NetServerFunction:SetCallback(func)
if self.instance.OnServerInvoke ~= nil then
error("[rbx-net] The callback for " .. self.instance.Name .. " is already set.\n" .. "\t* Changing this callback may lead to a different behaviour than expected from the client. " .. "Thus, it is not allowed.");
end;
if self.propTypes ~= nil then
self.instance.OnServerInvoke = function(player, ...)
local args = { ... };
if t_assert(self.propTypes, args) then
return func(player, unpack(args));
else
error("Client failed type checks", 2);
end;
end;
else
self.instance.OnServerInvoke = func;
end;
return self;
end;
function NetServerFunction:getInstance()
function NetServerFunction:GetInstance()
return self.instance;
end;
function NetServerFunction:getClientCache()
function NetServerFunction:GetClientCache()
local cache = self.instance:FindFirstChild("Cache");
if cache then
return cache.Value;
else
return 0;
end;
end;
function NetServerFunction:setClientCache(time)
function NetServerFunction:SetClientCache(time)
local cache = self.instance:FindFirstChild("Cache");
if not cache then
local cacheTimer = Instance.new("NumberValue", self.instance);
Expand All @@ -49,11 +86,6 @@ do
end;
return self;
end;
NetServerFunction.CallPlayerAsync = TS.async(function(self, player, ...)
local args = { ... };
warn("[rbx-net] CallPlayerAsync is possibly going to be removed\n" .. "\tsee https://github.com/roblox-aurora/rbx-net/issues/13 for more details.");
return self.instance:InvokeClient(player, unpack(args));
end);
end;
exports.default = NetServerFunction;
return exports;
14 changes: 11 additions & 3 deletions lualib/ServerThrottledEvent.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Compiled with https://roblox-ts.github.io v0.2.14
-- August 6, 2019, 7:32 PM New Zealand Standard Time
-- August 10, 2019, 6:58 PM New Zealand Standard Time

local TS = require(script.Parent.vendor.RuntimeLib);
local exports = {};
Expand All @@ -23,6 +23,14 @@ do
function NetServerThrottledEvent:constructor(name, rateLimit)
super.constructor(self, name);
self.maxRequestsPerMinute = 0;
self.setRateLimit = function(requestsPerMinute)
warn(self.instance.Name .. "::setRateLimit is deprecated, use " .. self.instance.Name .. "::SetRateLimit instead!");
return self:SetRateLimit(requestsPerMinute);
end;
self.getRateLimit = function()
warn(self.instance.Name .. "::getRateLimit is deprecated, use " .. self.instance.Name .. "::GetRateLimit instead!");
return self:GetRateLimit();
end;
self.maxRequestsPerMinute = rateLimit;
self.clientRequests = throttler:Get("Event~" .. name);
local clientValue = Instance.new("IntValue", self.instance);
Expand All @@ -46,7 +54,7 @@ do
end;
end);
end;
function NetServerThrottledEvent:setRateLimit(requestsPerMinute)
function NetServerThrottledEvent:SetRateLimit(requestsPerMinute)
self.maxRequestsPerMinute = requestsPerMinute;
local clientValue = self.instance:FindFirstChild("RateLimit");
if clientValue then
Expand All @@ -57,7 +65,7 @@ do
clientValue.Value = requestsPerMinute;
end;
end;
function NetServerThrottledEvent:getRateLimit()
function NetServerThrottledEvent:GetRateLimit()
return self.maxRequestsPerMinute;
end;
end;
Expand Down
Loading

0 comments on commit 7f47f71

Please sign in to comment.