diff --git a/FastNet2_Rewrite.rbxm b/FastNet2_Rewrite.rbxm index bd92307..aa16dd1 100644 Binary files a/FastNet2_Rewrite.rbxm and b/FastNet2_Rewrite.rbxm differ diff --git a/docs/api/1.0/signal.md b/docs/api/1.0/signal.md index 08309ff..1963aef 100644 --- a/docs/api/1.0/signal.md +++ b/docs/api/1.0/signal.md @@ -29,15 +29,15 @@ Listen an event to signal. Each signal event only allowed have one callback. ```lua -Remote:Connect(function(...) +Signal:Connect(function(...) print(...) end) ``` -to know if the event is connected or not by doing `.Connected` +to know if the signal is connected or not by doing `.Connected` ```lua -print(Remote.Connected) +print(Signal.Connected) ``` ## `:Once` @@ -51,22 +51,22 @@ This function is same as `:Connect` but it disconnect the signal once it fired. ``` ```lua -Remote:Once(function(...) +Signal:Once(function(...) print(...) end) ``` ## `:Disconnect` -Disconnect the event +Disconnect the signal ```lua -Remote:Disconnect() +Signal:Disconnect() ``` ## `:Fire` -Fire the event to the server with data. +Fire the signal with data. ```lua ( @@ -75,7 +75,7 @@ Fire the event to the server with data. ``` ```lua -Remote:Fire("Hello World!") +Signal:Fire("Hello World!") ``` ::: warning @@ -84,7 +84,7 @@ This function have rate limiting to prevent spamming ## `:Invoke` -Invoke is a function that invoke to server. +Invoke is a function that invoke to signal. ```lua ( @@ -94,7 +94,7 @@ Invoke is a function that invoke to server. ``` ```lua -local Request = Remote:Pull(2, "Hello World!") +local Request = Signal:Pull(2, "Hello World!") ``` ::: warning @@ -103,10 +103,10 @@ This function is yielded, and this function still on beta ## `:Wait` -Wait the event that triggered/pinged +Wait the signal that triggered/pinged ```lua -Remote:Wait() +Signal:Wait() ``` ::: warning @@ -115,8 +115,8 @@ This function is yielded ## `:Destroy` -Disconnect the event and Remove the event from FastNet2 +Disconnect the signal and remove the signal ```lua -Remote:Destroy() +Signal:Destroy() ``` \ No newline at end of file diff --git a/src/Client/init.luau b/src/Client/init.luau index c805ce4..d842dce 100644 --- a/src/Client/init.luau +++ b/src/Client/init.luau @@ -42,12 +42,10 @@ end **--]] function Client:Connect(callback: (...any) -> ()) - if self then - Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier)) - self.func = callback - Process.reg_pre_f(self.Identifier, callback) - self.Connected = true - end + Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier)) + self.func = callback + Process.reg_pre_f(self.Identifier, callback) + self.Connected = true end --[[** @@ -57,11 +55,9 @@ end **--]] function Client:ConnectParallel(callback: (...any) -> ()) - if self then - task.desynchronize() - self:Connect(callback) - task.synchronize() - end + task.desynchronize() + self:Connect(callback) + task.synchronize() end --[[** @@ -81,10 +77,7 @@ end **--]] function Client:Wait(): number - if self then - return Process._ping(self.Identifier) - end - return 0 + return Process._ping(self.Identifier) end --[[** @@ -94,7 +87,7 @@ end **--]] function Client:Once(callback: (...any) -> ()) - if self and not self.Connected then + if not self.Connected then self.func = function(...) self:Disconnect() task.spawn(callback, ...) @@ -108,7 +101,7 @@ end **--]] function Client:Disconnect() - if self and self.Connected then + if self.Connected then self.Connected = false Process.unreg_pre_f(self.Identifier) self.func = nil @@ -121,10 +114,8 @@ end function Client:Destroy() self:Disconnect() - if self then - Process.unreg(self.Identifier) - self = setmetatable(self, nil) - end + Process.unreg(self.Identifier) + setmetatable(self, nil) end --[[** diff --git a/src/Server/init.luau b/src/Server/init.luau index c1e4279..402a42b 100644 --- a/src/Server/init.luau +++ b/src/Server/init.luau @@ -40,12 +40,10 @@ end **--]] function Server:Connect(callback: (...any) -> ()) - if self then - Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier)) - self.func = callback - Process.reg_pre_f(self.Identifier, callback) - self.Connected = true - end + Debug.new(not self.Connected, string.format("[FastNet2]: %s already connected", self.Identifier)) + self.func = callback + Process.reg_pre_f(self.Identifier, callback) + self.Connected = true end --[[** @@ -55,11 +53,9 @@ end **--]] function Server:ConnectParallel(callback: (...any) -> ()) - if self then - task.desynchronize() - self:Connect(callback) - task.synchronize() - end + task.desynchronize() + self:Connect(callback) + task.synchronize() end --[[** @@ -69,9 +65,7 @@ end **--]] function Server:Listen(callback: (...any) -> ()) - if self then - self:Connect(callback) - end + self:Connect(callback) end --[[** @@ -79,10 +73,7 @@ end **--]] function Server:Wait(): number - if self then - return Process._ping(self.Identifier) - end - return 0 + return Process._ping(self.Identifier) end --[[** @@ -92,7 +83,7 @@ end **--]] function Server:Once(callback: (...any) -> ()) - if self and not self.Connected then + if not self.Connected then self.func = function(...) self:Disconnect() task.spawn(callback, ...) @@ -106,7 +97,7 @@ end **--]] function Server:Disconnect() - if self and self.Connected then + if self.Connected then self.Connected = false Process.unreg_pre_f(self.Identifier) self.func = nil @@ -119,10 +110,8 @@ end function Server:Destroy() self:Disconnect() - if self then - Process.unreg(self.Identifier) - self = setmetatable(self, nil) - end + Process.unreg(self.Identifier) + setmetatable(self, nil) end --[[**