diff --git a/docs/api/1.0/client.md b/docs/api/1.0/client.md index a76bb94..a2f2a2e 100644 --- a/docs/api/1.0/client.md +++ b/docs/api/1.0/client.md @@ -6,57 +6,64 @@ A Client-sided Connection Create new FastNet2 event -```lua +::: code-group +```lua [main] ( Identifier: string ) ``` -Identifier will converte/encode into hash identifier - -```lua +```lua [Example] local Remote = FastNet2.new("Remote") ``` +::: + +Identifier will converte/encode into hash identifier ## `:Connect` or `:Listen` Listen an event from the server to receive, `:Connect` and `:Listen` is the same function. -```lua +::: code-group +```lua [main] ( + player: Player, callback: (...any) -> () ) ``` -Each event only allowed have one callback. - -```lua -Remote:Connect(function(...) +```lua [Example] +Remote:Connect(function(player, ...) print(...) end) ``` -to know if the event is connected or not by doing `.Connected` - -```lua +```lua [Extra] +-- to know if the event is connected or not by doing `.Connected` print(Remote.Connected) ``` +::: + +Each event only allowed have one callback. ## `:Once` This function is same as `:Connect` but it disconnect the event once it fired. -```lua +::: code-group +```lua [main] ( + player: Player, callback: (...any) -> () ) ``` -```lua -Remote:Once(function(...) +```lua [Example] +Remote:Once(function(player, ...) print(...) end) ``` +::: ## `:Disconnect` @@ -68,17 +75,19 @@ Remote:Disconnect() ## `:Fire` -Fire the event to the server with data. +Fire the event to the spesific server with data. -```lua +::: code-group +```lua [main] ( ...: any ) ``` -```lua +```lua [Example] Remote:Fire("Hello World!") ``` +::: ::: warning This function have rate limiting to prevent spamming @@ -88,16 +97,18 @@ This function have rate limiting to prevent spamming Pull is a function that invoke to server. -```lua +::: code-group +```lua [main] ( timeout: number, ...: any ) -> (...any) ``` -```lua +```lua [Example] local Request = Remote:Pull(2, "Hello World!") ``` +::: ::: warning This function is yielded, and the minimum for timeout is 2 (seconds) diff --git a/docs/api/1.0/fastnet2.md b/docs/api/1.0/fastnet2.md index 02156e8..2db8246 100644 --- a/docs/api/1.0/fastnet2.md +++ b/docs/api/1.0/fastnet2.md @@ -1,4 +1,4 @@ -# FastNet2 +# FastNet2 The public main of the FastNet2 library. diff --git a/docs/api/1.0/server.md b/docs/api/1.0/server.md index e1959bf..7584f43 100644 --- a/docs/api/1.0/server.md +++ b/docs/api/1.0/server.md @@ -6,58 +6,64 @@ A Server-sided Connection Create new FastNet2 event -```lua +::: code-group +```lua [main] ( Identifier: string ) ``` -Identifier will converte/encode into hash identifier - -```lua +```lua [Example] local Remote = FastNet2.new("Remote") ``` +::: + +Identifier will converte/encode into hash identifier ## `:Connect` or `:Listen` -Listen an event from the server to receive, `:Connect` and `:Listen` is the same function. +Listen an event from the client to receive, `:Connect` and `:Listen` is the same function. -```lua +::: code-group +```lua [main] ( player: Player, callback: (...any) -> () ) ``` -Each event only allowed have one callback. - -```lua +```lua [Example] Remote:Connect(function(player, ...) print(...) end) ``` -to know if the event is connected or not by doing `.Connected` - -```lua +```lua [Extra] +-- to know if the event is connected or not by doing `.Connected` print(Remote.Connected) ``` +::: + +Each event only allowed have one callback. + ## `:Once` This function is same as `:Connect` but it disconnect the event once it fired. -```lua +::: code-group +```lua [main] ( player: Player, callback: (...any) -> () ) ``` -```lua +```lua [Example] Remote:Once(function(player, ...) print(...) end) ``` +::: ## `:Disconnect` @@ -71,44 +77,41 @@ Remote:Disconnect() Fire the event to the spesific client with data. -```lua +::: code-group +```lua [main] ( player: Player, ...: any ) ``` -```lua +```lua [Example] Remote:Fire(player, "Hello World!") ``` - -::: warning -This function have rate limiting to prevent spamming ::: -## `:Fires` +## `:Fires` Fire the event to all clients with data. -```lua +::: code-group +```lua [main] ( ...: any ) ``` -```lua +```lua [Example] Remote:Fires("Hello World!") ``` - -::: warning -This function have rate limiting to prevent spamming ::: ## `:Pull` -Pull is a function that invoke to server. +Pull is a function that invoke to client. -```lua +::: code-group +```lua [main] ( timeout: number, player: Player, @@ -116,9 +119,10 @@ Pull is a function that invoke to server. ) -> (...any) ``` -```lua +```lua [Example] local Request = Remote:Pull(2, player, "Hello World!") ``` +::: ::: warning This function is yielded, and the minimum for timeout is 2 (seconds) diff --git a/docs/api/1.0/signal.md b/docs/api/1.0/signal.md index b09d51d..e12b25f 100644 --- a/docs/api/1.0/signal.md +++ b/docs/api/1.0/signal.md @@ -6,55 +6,60 @@ Signal (an alternative for bindable events) Create new Signal event -```lua +::: code-group +```lua [main] ( Identifier: string ) ``` -```lua +```lua [Example] local Signal = FastNet2.Signal("TestSignal") ``` +::: ## `:Connect` Listen an event to signal. -```lua +::: code-group +```lua [main] ( callback: (...any) -> () ) ``` -Each signal event only allowed have one callback. - -```lua +```lua [Example] Signal:Connect(function(...) print(...) end) ``` -to know if the signal is connected or not by doing `.Connected` - -```lua +```lua [Extra] +-- to know if the signal is connected or not by doing `.Connected` print(Signal.Connected) ``` +::: + +Each signal event only allowed have one callback. ## `:Once` This function is same as `:Connect` but it disconnect the signal once it fired. -```lua +::: code-group +```lua [main] ( callback: (...any) -> () ) ``` -```lua +```lua [Example] Signal:Once(function(...) print(...) end) ``` +::: ## `:Disconnect` @@ -68,37 +73,37 @@ Signal:Disconnect() Fire the signal with data. -```lua +::: code-group +```lua [main] ( ...: any ) ``` -```lua +```lua [Example] Signal:Fire("Hello World!") ``` - -::: warning -This function have rate limiting to prevent spamming ::: ## `:Invoke` Invoke is a function that invoke to signal. -```lua +::: code-group +```lua [main] ( timeout: number, ...: any ) -> (...any) ``` -```lua +```lua [Example] local Request = Signal:Invoke(2, "Hello World!") ``` +::: ::: warning -This function is yielded, and this function still on beta +This function is yielded ::: ## `:Wait` diff --git a/docs/guide/example.md b/docs/guide/example.md index 1f4ec2b..38fae8d 100644 --- a/docs/guide/example.md +++ b/docs/guide/example.md @@ -2,9 +2,8 @@ Let's try and play something with FastNet2! -## Server-Side - -```lua +::: code-group +```lua [Server] local FastNet2 = require("path.to.module") -- Events @@ -27,9 +26,7 @@ Ping:Connect(function(player, ping) end) ``` -## Client-Side - -```lua +```lua [Client] local Players = game:GetService("Players") local FastNet2 = require("path.to.module") diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index c34113a..ca13a79 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -1,17 +1,20 @@ # Getting Started +### Step 1: First, you have to require the module ```lua local FastNet2 = require('path.to.module'); ``` +### Step 2: Then, to create a new event you have to use `.new` function ```lua local Remote = FastNet2.new("EventName"); ``` +### Step 3: Firing event everytime player join ```lua @@ -21,4 +24,7 @@ Players.PlayerAdded:Connect(function(player) Remote:Fire(player, "Welcome!") end) ``` -FastNet2 have built-in feature called `pre-process` that could wait until the player event is being connected, so you dont have worry about that! \ No newline at end of file + +::: tip +FastNet2 have built-in feature called `pre-process` that could wait until the player event is being connected, so you dont have worry about that! +::: \ No newline at end of file