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 16be5da commit c8fa5ac
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 59 deletions.
Binary file modified FastNet2_Rewrite.rbxm
Binary file not shown.
28 changes: 14 additions & 14 deletions docs/api/1.0/signal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
(
Expand All @@ -75,7 +75,7 @@ Fire the event to the server with data.
```

```lua
Remote:Fire("Hello World!")
Signal:Fire("Hello World!")
```

::: warning
Expand All @@ -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
(
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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()
```
33 changes: 12 additions & 21 deletions src/Client/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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

--[[**
Expand All @@ -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

--[[**
Expand All @@ -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

--[[**
Expand All @@ -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, ...)
Expand All @@ -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
Expand All @@ -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

--[[**
Expand Down
37 changes: 13 additions & 24 deletions src/Server/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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

--[[**
Expand All @@ -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

--[[**
Expand All @@ -69,20 +65,15 @@ end
**--]]

function Server:Listen(callback: (...any) -> ())
if self then
self:Connect(callback)
end
self:Connect(callback)
end

--[[**
Wait Connection is being process
**--]]

function Server:Wait(): number
if self then
return Process._ping(self.Identifier)
end
return 0
return Process._ping(self.Identifier)
end

--[[**
Expand All @@ -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, ...)
Expand All @@ -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
Expand All @@ -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

--[[**
Expand Down

0 comments on commit c8fa5ac

Please sign in to comment.