Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
re-update rc9 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
imezx committed Sep 6, 2023
1 parent c8fa5ac commit 9176998
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
Binary file modified FastNet2_Rewrite.rbxm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Client/Process.luau
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ClientProcess.unreg(Identifier: string)
end

function ClientProcess.insert(Identifier: string, obj)
if not Debug.new(Collections[Identifier].OutgoingOrder < ClientProcess.rateLimit, "[FastNet2]: Unable to call :Fire (rate-limit reached)") then return end
if not Debug.new(Collections[Identifier].OutgoingOrder < ClientProcess.rateLimit, "[FastNet2]: Unable to call :Fire (rate-limit reached)", 1) then return end
Collections[Identifier].OutgoingOrder += 1
Outgoing[Identifier][Collections[Identifier].OutgoingOrder] = obj
end
Expand Down
12 changes: 6 additions & 6 deletions src/Client/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ local Collections = {}
**--]]

function Client.new(Identifier: string)
Debug.new(typeof(Identifier) == "string", "[FastNet2]: Identifier must be string")
Debug.new(not Identifiers.find(Util.hash(Identifier)), string.format("[FastNet2]: %s already exist", Identifier))
Debug.new(typeof(Identifier) == "string", "[FastNet2]: Identifier must be string", 0)
Debug.new(not Identifiers.find(Util.hash(Identifier)), string.format("[FastNet2]: %s already exist", Identifier), 0)
Process.reg(Util.hash(Identifier))
Collections[Util.hash(Identifier)] = setmetatable({
Identifier = Util.hash(Identifier),
Expand All @@ -42,7 +42,7 @@ end
**--]]

function Client:Connect(callback: (...any) -> ())
Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier))
Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier), 0)
self.func = callback
Process.reg_pre_f(self.Identifier, callback)
self.Connected = true
Expand Down Expand Up @@ -140,9 +140,9 @@ end
**--]]

function Client:Pull(timeout: number, ...: any)
Debug.new(typeof(timeout) == "number", "[FastNet2]: expire argument must be a number.")
Debug.new(timeout > 1, "[FastNet2]: expire argument must be minimum 2.")
Debug.new(#{...} > 0, "[FastNet2]: Unable to invoke without data")
Debug.new(typeof(timeout) == "number", "[FastNet2]: expire argument must be a number.", 0)
Debug.new(timeout > 1, "[FastNet2]: expire argument must be minimum 2.", 0)
Debug.new(#{...} > 0, "[FastNet2]: Unable to invoke without data", 0)
local thread, requestId = coroutine.running(), tostring(#self.flag + 1)
local session = task.delay(timeout, function()
-- session expire
Expand Down
11 changes: 7 additions & 4 deletions src/Debug.luau
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
--!strict

local Debug = {}

local Logs = {}

function Debug.new(condition: any, message: string): boolean
table.insert(Logs, message.." ("..((condition) == true and "PASS" or "ERR")..")")
if not (condition) then error(message, 2) end
function Debug.new(condition: any, message: string, safe: number): boolean
if safe == 1 then
if not (condition) then warn(message) end
else
table.insert(Logs, message.." ("..((condition) == true and "PASS" or "ERR")..")")
if not (condition) then error(message, 2) end
end
return (condition)
end

Expand Down
14 changes: 7 additions & 7 deletions src/Server/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ local Collections = {}
**--]]

function Server.new(Identifier: string)
Debug.new(typeof(Identifier) == "string", "[FastNet2]: Identifier must be string")
Debug.new(not Identifiers.find(Util.hash(Identifier)), string.format("[FastNet2]: %s already exist", Identifier))
Debug.new(typeof(Identifier) == "string", "[FastNet2]: Identifier must be string", 0)
Debug.new(not Identifiers.find(Util.hash(Identifier)), string.format("[FastNet2]: %s already exist", Identifier), 0)
Process.reg(Util.hash(Identifier))
Collections[Util.hash(Identifier)] = setmetatable({
Identifier = Util.hash(Identifier),
Expand All @@ -40,7 +40,7 @@ end
**--]]

function Server:Connect(callback: (...any) -> ())
Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier))
Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier), 0)
self.func = callback
Process.reg_pre_f(self.Identifier, callback)
self.Connected = true
Expand Down Expand Up @@ -145,10 +145,10 @@ end
**--]]

function Server:Pull(timeout: number, player: Player, ...: any)
Debug.new(typeof(timeout) == "number", "[FastNet2]: expire argument must be a number.")
Debug.new(timeout > 1, "[FastNet2]: expire argument must be minimum 2.")
Debug.new(player:IsA("Player"), "[FastNet2]: player argument must be a Player.")
Debug.new(#{...} > 0, "[FastNet2]: Unable to invoke without data")
Debug.new(typeof(timeout) == "number", "[FastNet2]: expire argument must be a number.", 0)
Debug.new(timeout > 1, "[FastNet2]: expire argument must be minimum 2.", 0)
Debug.new(player:IsA("Player"), "[FastNet2]: player argument must be a Player.", 0)
Debug.new(#{...} > 0, "[FastNet2]: Unable to invoke without data", 0)
local thread, requestId = coroutine.running(), tostring(#self.flag + 1)
local session = task.delay(timeout, function()
-- session expire
Expand Down
2 changes: 1 addition & 1 deletion src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end
**--]]

function FastNet2.CheckUpdate()
Debug.new(IsServer, "[FastNet2]: Unable to check update due ROBLOX Security.")
Debug.new(IsServer, "[FastNet2]: Unable to check update due ROBLOX Security.", 1)
local success: boolean, receive: number = pcall(function()
return tonumber(
HttpService:GetAsync("https://raw.githubusercontent.com/imezx/FastNet2/master/VERSION", true)
Expand Down
12 changes: 6 additions & 6 deletions src/oneSignal.luau
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ local Collections = {}
local Debug = require(script.Parent.Debug)

function oneSignal.new(identifier: string)
Debug.new(typeof(identifier) == "string", "[oneSignal]: Identifier must be string")
Debug.new(not Collections[identifier], string.format("[oneSignal]: %s already exist", identifier))
Debug.new(typeof(identifier) == "string", "[oneSignal]: Identifier must be string", 0)
Debug.new(not Collections[identifier], string.format("[oneSignal]: %s already exist", identifier), 0)
Collections[identifier] = setmetatable({
cb = nil,
Connected = false,
Expand All @@ -25,22 +25,22 @@ function oneSignal.new(identifier: string)
end

function oneSignal.get(identifier: string)
Debug.new(Collections[identifier], string.format("[oneSignal]: %s not exist", identifier))
Debug.new(Collections[identifier], string.format("[oneSignal]: %s not exist", identifier), 0)
return Collections[identifier]
end

function oneSignal:Connect(callback: (...any) -> ())
if self then
Debug.new(not self.Connected, string.format("[oneSignal]: %s already connected", self.Identifier))
Debug.new(not self.Connected, string.format("[oneSignal]: %s already connected", self.Identifier), 0)
self.cb = callback
self.Connected = true
end
end

function oneSignal:Invoke(timeout: number, ...: any): any
if self then
Debug.new(typeof(timeout) == "number", string.format("[oneSignal]: timeout must be number, got %s", typeof(timeout)))
Debug.new(#{...} > 0, "[oneSignal]: Unable to invoke without data")
Debug.new(typeof(timeout) == "number", string.format("[oneSignal]: timeout must be number, got %s", typeof(timeout)), 0)
Debug.new(#{...} > 0, "[oneSignal]: Unable to invoke without data", 0)
timeout = math.max(1, timeout)
local thread, packed, retrive = coroutine.running(), { ... }, nil
local session = task.delay(timeout, function()
Expand Down

0 comments on commit 9176998

Please sign in to comment.