Skip to content

Commit 7f47f71

Browse files
author
Jonathan Holmes
committed
Update LuaBundle to 1.1.0
1 parent 5eb7d0f commit 7f47f71

12 files changed

+171
-55
lines changed

lualib/ClientEvent.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};
@@ -27,14 +27,14 @@ do
2727
end;
2828
return NetClientEvent.new(name);
2929
end);
30-
function NetClientEvent:getInstance()
30+
function NetClientEvent:GetInstance()
3131
return self.instance;
3232
end;
33-
function NetClientEvent:getEvent()
33+
function NetClientEvent:GetEvent()
3434
return self.instance.OnClientEvent;
3535
end;
3636
function NetClientEvent:Connect(callback)
37-
return self:getEvent():Connect(callback);
37+
return self:GetEvent():Connect(callback);
3838
end;
3939
function NetClientEvent:SendToServer(...)
4040
local args = { ... };

lualib/ClientFunction.lua

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};
@@ -19,6 +19,14 @@ do
1919
function NetClientFunction:constructor(name)
2020
self.lastPing = -1;
2121
self.cached = {};
22+
self.getCache = function()
23+
warn(self.instance.Name .. "::getCache is deprecated, use " .. self.instance.Name .. "::GetCache instead!");
24+
return self:GetCache();
25+
end;
26+
self.getInstance = function()
27+
warn(self.instance.Name .. "::getInstance is deprecated, use " .. self.instance.Name .. "::GetInstance instead!");
28+
return self:GetInstance();
29+
end;
2230
self.instance = getRemoteOrThrow("RemoteFunction", name);
2331
assert(IS_CLIENT, "Cannot create a Net.ClientFunction on the Server!");
2432
assert(functionExists(name), "The specified function '" .. name .. "' does not exist!");
@@ -30,16 +38,10 @@ do
3038
end;
3139
return NetClientFunction.new(name);
3240
end);
33-
function NetClientFunction:getCallback()
34-
return self.instance.OnClientInvoke;
35-
end;
36-
function NetClientFunction:setCallback(func)
37-
self.instance.OnClientInvoke = func;
38-
end;
39-
function NetClientFunction:getInstance()
41+
function NetClientFunction:GetInstance()
4042
return self.instance;
4143
end;
42-
function NetClientFunction:getCache()
44+
function NetClientFunction:GetCache()
4345
local cache = self.instance:FindFirstChild("Cache");
4446
if cache then
4547
return cache.Value;
@@ -49,7 +51,7 @@ do
4951
end;
5052
function NetClientFunction:CallServer(...)
5153
local args = { ... };
52-
if self.lastPing < os.time() + self:getCache() then
54+
if self.lastPing < os.time() + self:GetCache() then
5355
local result = self.instance:InvokeServer(unpack(args));
5456
self.cached = result;
5557
self.lastPing = os.time();

lualib/GlobalClientEvent.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};

lualib/GlobalEvent.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};

lualib/GlobalServerEvent.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};

lualib/ServerEvent.lua

+50-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};
6+
local NetServerEvent;
67
local _0 = TS.import(script.Parent, "internal");
7-
local findOrCreateRemote, IS_CLIENT = _0.findOrCreateRemote, _0.IS_CLIENT;
8+
local findOrCreateRemote, IS_CLIENT, t_assert = _0.findOrCreateRemote, _0.IS_CLIENT, _0.t_assert;
89
local Players = game:GetService("Players");
9-
local NetServerEvent;
1010
do
1111
NetServerEvent = setmetatable({}, {
1212
__tostring = function() return "NetServerEvent" end;
@@ -17,52 +17,90 @@ do
1717
self:constructor(...);
1818
return self;
1919
end;
20-
function NetServerEvent:constructor(name)
20+
function NetServerEvent:constructor(name, ...)
21+
local recievedPropTypes = { ... };
2122
self.instance = findOrCreateRemote("RemoteEvent", name);
2223
assert(not IS_CLIENT, "Cannot create a Net.ServerEvent on the Client!");
24+
if #recievedPropTypes > 0 then
25+
self.propTypes = recievedPropTypes;
26+
end;
27+
end;
28+
function NetServerEvent:WithStrictCall(...)
29+
local callPropTypes = { ... };
30+
self.callTypes = callPropTypes;
31+
return self;
2332
end;
24-
function NetServerEvent:getInstance()
33+
function NetServerEvent:GetInstance()
2534
return self.instance;
2635
end;
27-
function NetServerEvent:getEvent()
36+
function NetServerEvent:GetEvent()
2837
return self.instance.OnServerEvent;
2938
end;
3039
function NetServerEvent:Connect(callback)
31-
return self:getEvent():Connect(callback);
40+
if self.propTypes ~= nil then
41+
return self:GetEvent():Connect(function(sourcePlayer, ...)
42+
local args = { ... };
43+
if t_assert(self.propTypes, args) then
44+
callback(sourcePlayer, unpack(args));
45+
end;
46+
end);
47+
else
48+
return self:GetEvent():Connect(callback);
49+
end;
3250
end;
3351
function NetServerEvent:SendToAllPlayers(...)
3452
local args = { ... };
35-
self.instance:FireAllClients(unpack(args));
53+
if self.callTypes ~= nil then
54+
if not t_assert(self.callTypes, args) then
55+
return nil;
56+
end;
57+
end;
58+
self.instance:FireAllClients(unpack((args)));
3659
end;
3760
function NetServerEvent:SendToAllPlayersExcept(blacklist, ...)
3861
local args = { ... };
62+
if self.callTypes ~= nil then
63+
if not t_assert(self.callTypes, args) then
64+
return nil;
65+
end;
66+
end;
3967
if (typeof(blacklist) == "Instance") then
4068
local otherPlayers = TS.array_filter(Players:GetPlayers(), function(p)
4169
return p ~= blacklist;
4270
end);
4371
for _1 = 1, #otherPlayers do
4472
local player = otherPlayers[_1];
45-
self.instance:FireClient(player, unpack(args));
73+
self.instance:FireClient(player, unpack((args)));
4674
end;
4775
elseif (typeof(blacklist) == "table") then
4876
local _1 = Players:GetPlayers();
4977
for _2 = 1, #_1 do
5078
local player = _1[_2];
5179
if TS.array_indexOf(blacklist, player) == -1 then
52-
self.instance:FireClient(player, unpack(args));
80+
self.instance:FireClient(player, unpack((args)));
5381
end;
5482
end;
5583
end;
5684
end;
5785
function NetServerEvent:SendToPlayer(player, ...)
5886
local args = { ... };
59-
self.instance:FireClient(player, unpack(args));
87+
if self.callTypes ~= nil then
88+
if not t_assert(self.callTypes, args) then
89+
return nil;
90+
end;
91+
end;
92+
self.instance:FireClient(player, unpack((args)));
6093
end;
6194
function NetServerEvent:SendToPlayers(players, ...)
6295
local args = { ... };
96+
if self.callTypes ~= nil then
97+
if not t_assert(self.callTypes, args) then
98+
return nil;
99+
end;
100+
end;
63101
for _1 = 1, #players do
64102
local player = players[_1];
65-
self:SendToPlayer(player, unpack(args));
103+
self:SendToPlayer(player, unpack((args)));
66104
end;
67105
end;
68106
end;

lualib/ServerFunction.lua

+46-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};
66
local _0 = TS.import(script.Parent, "internal");
7-
local findOrCreateRemote, IS_CLIENT = _0.findOrCreateRemote, _0.IS_CLIENT;
7+
local findOrCreateRemote, IS_CLIENT, t_assert = _0.findOrCreateRemote, _0.IS_CLIENT, _0.t_assert;
8+
local function t_string(value)
9+
return true;
10+
end;
811
local NetServerFunction;
912
do
1013
NetServerFunction = setmetatable({}, {
@@ -16,29 +19,63 @@ do
1619
self:constructor(...);
1720
return self;
1821
end;
19-
function NetServerFunction:constructor(name)
22+
function NetServerFunction:constructor(name, ...)
23+
local recievedPropTypes = { ... };
24+
self.getCallback = function()
25+
warn(self.instance.Name .. "::getCallback is deprecated, use " .. self.instance.Name .. "::GetCallback instead!");
26+
return self:GetCallback();
27+
end;
28+
self.getClientCache = function()
29+
warn(self.instance.Name .. "::getClientCache is deprecated, use " .. self.instance.Name .. "::GetClientCache instead!");
30+
return self:GetClientCache();
31+
end;
32+
self.setCallback = function(func)
33+
warn(self.instance.Name .. "::setCallback is deprecated, use " .. self.instance.Name .. "::SetCallback instead!");
34+
return self:SetCallback(func);
35+
end;
36+
self.setClientCache = function(timeout)
37+
warn(self.instance.Name .. "::setClientCache is deprecated, use " .. self.instance.Name .. "::SetClientCache instead!");
38+
return self:SetClientCache(timeout);
39+
end;
2040
self.instance = findOrCreateRemote("RemoteFunction", name);
2141
assert(not IS_CLIENT, "Cannot create a Net.ServerFunction on the Client!");
42+
if #recievedPropTypes > 0 then
43+
self.propTypes = recievedPropTypes;
44+
end;
2245
end;
23-
function NetServerFunction:getCallback()
46+
function NetServerFunction:GetCallback()
2447
return self.instance.OnServerInvoke;
2548
end;
26-
function NetServerFunction:setCallback(func)
27-
self.instance.OnServerInvoke = func;
49+
function NetServerFunction:SetCallback(func)
50+
if self.instance.OnServerInvoke ~= nil then
51+
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.");
52+
end;
53+
if self.propTypes ~= nil then
54+
self.instance.OnServerInvoke = function(player, ...)
55+
local args = { ... };
56+
if t_assert(self.propTypes, args) then
57+
return func(player, unpack(args));
58+
else
59+
error("Client failed type checks", 2);
60+
end;
61+
end;
62+
else
63+
self.instance.OnServerInvoke = func;
64+
end;
2865
return self;
2966
end;
30-
function NetServerFunction:getInstance()
67+
function NetServerFunction:GetInstance()
3168
return self.instance;
3269
end;
33-
function NetServerFunction:getClientCache()
70+
function NetServerFunction:GetClientCache()
3471
local cache = self.instance:FindFirstChild("Cache");
3572
if cache then
3673
return cache.Value;
3774
else
3875
return 0;
3976
end;
4077
end;
41-
function NetServerFunction:setClientCache(time)
78+
function NetServerFunction:SetClientCache(time)
4279
local cache = self.instance:FindFirstChild("Cache");
4380
if not cache then
4481
local cacheTimer = Instance.new("NumberValue", self.instance);
@@ -49,11 +86,6 @@ do
4986
end;
5087
return self;
5188
end;
52-
NetServerFunction.CallPlayerAsync = TS.async(function(self, player, ...)
53-
local args = { ... };
54-
warn("[rbx-net] CallPlayerAsync is possibly going to be removed\n" .. "\tsee https://github.com/roblox-aurora/rbx-net/issues/13 for more details.");
55-
return self.instance:InvokeClient(player, unpack(args));
56-
end);
5789
end;
5890
exports.default = NetServerFunction;
5991
return exports;

lualib/ServerThrottledEvent.lua

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Compiled with https://roblox-ts.github.io v0.2.14
2-
-- August 6, 2019, 7:32 PM New Zealand Standard Time
2+
-- August 10, 2019, 6:58 PM New Zealand Standard Time
33

44
local TS = require(script.Parent.vendor.RuntimeLib);
55
local exports = {};
@@ -23,6 +23,14 @@ do
2323
function NetServerThrottledEvent:constructor(name, rateLimit)
2424
super.constructor(self, name);
2525
self.maxRequestsPerMinute = 0;
26+
self.setRateLimit = function(requestsPerMinute)
27+
warn(self.instance.Name .. "::setRateLimit is deprecated, use " .. self.instance.Name .. "::SetRateLimit instead!");
28+
return self:SetRateLimit(requestsPerMinute);
29+
end;
30+
self.getRateLimit = function()
31+
warn(self.instance.Name .. "::getRateLimit is deprecated, use " .. self.instance.Name .. "::GetRateLimit instead!");
32+
return self:GetRateLimit();
33+
end;
2634
self.maxRequestsPerMinute = rateLimit;
2735
self.clientRequests = throttler:Get("Event~" .. name);
2836
local clientValue = Instance.new("IntValue", self.instance);
@@ -46,7 +54,7 @@ do
4654
end;
4755
end);
4856
end;
49-
function NetServerThrottledEvent:setRateLimit(requestsPerMinute)
57+
function NetServerThrottledEvent:SetRateLimit(requestsPerMinute)
5058
self.maxRequestsPerMinute = requestsPerMinute;
5159
local clientValue = self.instance:FindFirstChild("RateLimit");
5260
if clientValue then
@@ -57,7 +65,7 @@ do
5765
clientValue.Value = requestsPerMinute;
5866
end;
5967
end;
60-
function NetServerThrottledEvent:getRateLimit()
68+
function NetServerThrottledEvent:GetRateLimit()
6169
return self.maxRequestsPerMinute;
6270
end;
6371
end;

0 commit comments

Comments
 (0)