diff --git a/docs/api/1.0/client.md b/docs/api/1.0/client.md
index 8ea0e9f..2c3cce7 100644
--- a/docs/api/1.0/client.md
+++ b/docs/api/1.0/client.md
@@ -7,13 +7,13 @@ For Client-sided
Create new Warp event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
Identifier: string
)
```
-```lua [Example]
+```luau [Example]
local Remote = Warp.Client("Remote")
```
:::
@@ -23,13 +23,13 @@ local Remote = Warp.Client("Remote")
Create new Warp events with array.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
{ any }
)
```
-```lua [Example]
+```luau [Example]
local Events = Warp.fromClientArray({
"Remote1",
"Remote2",
@@ -48,13 +48,13 @@ Events.Remote3:Connect(function(...) end)
Connect event to receive incoming from server way.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
callback: (...any) -> ()
)
```
-```lua [Example]
+```luau [Example]
Remote:Connect(function(...)
print(...)
end)
@@ -66,13 +66,13 @@ end)
This function likely `:Connect` but it disconnect the event once it fired.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
callback: (...any) -> ()
)
```
-```lua [Example]
+```luau [Example]
Remote:Once(function(...)
print(...)
end)
@@ -84,13 +84,13 @@ end)
Disconnect the event connection.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
key: string
): boolean
```
-```lua [Example]
+```luau [Example]
local connection = Remote:Connect(function(player, ...) end) -- store the key
Remote:Disconnect(connection)
@@ -101,7 +101,7 @@ Remote:Disconnect(connection)
Disconnect All the event connection.
-```lua [Example]
+```luau [Example]
Remote:DisconnectAll()
```
@@ -110,14 +110,14 @@ Remote:DisconnectAll()
Fire the event to the spesific server with data.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
reliable: boolean,
...: any
)
```
-```lua [Example]
+```luau [Example]
Remote:Fire(true, "Hello World!")
```
:::
@@ -131,14 +131,14 @@ This function have rate limiting it self and configured from server.
Semiliar to `:InvokeServer`, but it have timeout system that not exists on `RemoteFunction.InvokeServer`.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
timeout: number,
...: any
) -> (...any)
```
-```lua [Example]
+```luau [Example]
local Request = Remote:Invoke(2, "Hello World!") -- this yield until it response
```
:::
diff --git a/docs/api/1.0/ratelimit.md b/docs/api/1.0/ratelimit.md
index d3c6048..f579611 100644
--- a/docs/api/1.0/ratelimit.md
+++ b/docs/api/1.0/ratelimit.md
@@ -9,7 +9,7 @@ Ratelimit is one of most useful feature.
When creating a event on Server, you can add second argument (optional) as table `rateLimit` to limit the number of times the event can be called and the interval for reset the counter on client-side.
::: code-group
-```lua [Server]
+```luau [Server]
-- Server
-- Let's make the event have ratelimit with max 50 entrance for 2 seconds.
local Remote = Warp.Server("Remote1", {
@@ -22,7 +22,7 @@ local Remote = Warp.Server("Remote1", {
-- No need anything to adds on client side.
```
-```lua [Client]
+```luau [Client]
-- Client
local Remote = Warp.Client("Remote1") -- Yields, retreive rateLimit configuration.
-- The Event will automatic it self for retreiving the rate limit configuration from the server.
diff --git a/docs/api/1.0/server.md b/docs/api/1.0/server.md
index 554e5e6..27b1c42 100644
--- a/docs/api/1.0/server.md
+++ b/docs/api/1.0/server.md
@@ -7,7 +7,7 @@ For Server-sided
Create new Warp event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
Identifier: string,
rateLimit: {
@@ -17,7 +17,7 @@ Create new Warp event.
)
```
-```lua [Example]
+```luau [Example]
local Remote = Warp.Server("Remote")
```
:::
@@ -27,13 +27,13 @@ local Remote = Warp.Server("Remote")
Create new Warp events with array.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
{ any }
)
```
-```lua [Example]
+```luau [Example]
local Events = Warp.fromServerArray({
["Remote1"] = {
rateLimit = {
@@ -60,14 +60,14 @@ Events.Remote3:Connect(function(player, ...) end)
Connect event to receive incoming from client way.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
player: Player,
callback: (...any) -> ()
): string
```
-```lua [Example]
+```luau [Example]
Remote:Connect(function(player, ...)
print(player, ...)
end)
@@ -79,14 +79,14 @@ end)
This function likely `:Connect` but it disconnect the event once it fired.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
player: Player,
callback: (...any) -> ()
)
```
-```lua [Example]
+```luau [Example]
Remote:Once(function(player, ...)
print(player, ...)
end)
@@ -98,13 +98,13 @@ end)
Disconnect the event connection.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
key: string
): boolean
```
-```lua [Example]
+```luau [Example]
local connection = Remote:Connect(function(player, ...) end) -- store the key
Remote:Disconnect(connection)
@@ -115,7 +115,7 @@ Remote:Disconnect(connection)
Disconnect All the event connection.
-```lua [Example]
+```luau [Example]
Remote:DisconnectAll()
```
@@ -124,7 +124,7 @@ Remote:DisconnectAll()
Fire the event to a client.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
reliable: boolean,
player: Player,
@@ -132,7 +132,7 @@ Fire the event to a client.
)
```
-```lua [Example]
+```luau [Example]
Remote:Fire(true, player, "Hello World!")
```
:::
@@ -142,14 +142,14 @@ Remote:Fire(true, player, "Hello World!")
Fire the event to all clients.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
reliable: boolean,
...: any
)
```
-```lua [Example]
+```luau [Example]
Remote:Fires(true, "Hello World!")
```
:::
@@ -159,7 +159,7 @@ Remote:Fires(true, "Hello World!")
Fire the event to all clients but except a players.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
reliable: boolean,
except: { Player },
@@ -167,7 +167,7 @@ Fire the event to all clients but except a players.
)
```
-```lua [Example]
+```luau [Example]
Remote:FireExcept(true, { Players.Eternity_Devs, Players.Player2 }, "Hello World!") -- this will sent to all players except { Players.Eternity_Devs, Players.Player2 }.
```
:::
@@ -177,7 +177,7 @@ Remote:FireExcept(true, { Players.Eternity_Devs, Players.Player2 }, "Hello World
Semiliar to `:InvokeClient`, but it have timeout system that not exists on `RemoteFunction.InvokeClient`.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
timeout: number,
player: Player,
@@ -185,7 +185,7 @@ Semiliar to `:InvokeClient`, but it have timeout system that not exists on `Rem
) -> (...any)
```
-```lua [Example]
+```luau [Example]
local Request = Remote:Invoke(2, player, "Hello World!")
```
:::
diff --git a/docs/api/1.0/signal.md b/docs/api/1.0/signal.md
index 6985a9d..5404007 100644
--- a/docs/api/1.0/signal.md
+++ b/docs/api/1.0/signal.md
@@ -7,13 +7,13 @@ A alternative of BindableEvent.
Create new Signal.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
Identifier: string
)
```
-```lua [Example]
+```luau [Example]
local Signal1 = Warp.Signal("Signal1")
```
:::
@@ -23,13 +23,13 @@ local Signal1 = Warp.Signal("Signal1")
Create new Signal.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
{ string }
)
```
-```lua [Example]
+```luau [Example]
local Signals = Warp.fromSignalArray({"Signal1", "Signal2"})
Signals.Signal1:Connect(function(...) end)
Signals.Signal2:Connect(function(...) end)
@@ -39,13 +39,13 @@ Signals.Signal2:Connect(function(...) end)
## `:Connect`
::: code-group
-```lua [Variable]
+```luau [Variable]
(
callback: (...any) -> ()
)
```
-```lua [Example]
+```luau [Example]
Signal1:Connect(function(...)
print(...)
end)
@@ -57,13 +57,13 @@ end)
This function likely `:Connect` but it disconnect the signal once it fired.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
callback: (...any) -> ()
)
```
-```lua [Example]
+```luau [Example]
Signal1:Once(function(...)
print(...)
end)
@@ -75,13 +75,13 @@ end)
Disconnect the signal connection.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
key: string
)
```
-```lua [Example]
+```luau [Example]
local connection = Signal1:Connect(function(...) end) -- store the key
Signal1:Disconnect(connection)
@@ -96,7 +96,7 @@ This requires `key` to disconnect a signal connection.
Disconnect All signal connections.
-```lua [Example]
+```luau [Example]
Signal1:DisconnectAll()
```
@@ -105,13 +105,13 @@ Signal1:DisconnectAll()
Fire the signal (Immediate)
::: code-group
-```lua [Variable]
+```luau [Variable]
(
...: any
)
```
-```lua [Example]
+```luau [Example]
Signal1:Fire("Hello World!")
```
:::
@@ -121,13 +121,13 @@ Signal1:Fire("Hello World!")
Fire the signal (Deferred)
::: code-group
-```lua [Variable]
+```luau [Variable]
(
...: any
)
```
-```lua [Example]
+```luau [Example]
Signal1:Fire("Hello World!")
```
:::
@@ -141,14 +141,14 @@ This uses `pcall`, which means it never error (safe-mode, sacrificed debugging),
Fire to other signal, this uses `:Fire`.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
signal: string,
...: any
)
```
-```lua [Example]
+```luau [Example]
Signals.Signal1:FireTo("Signal2", "Hello World!")
```
:::
@@ -160,14 +160,14 @@ This requires `key`.
## `:Invoke`
::: code-group
-```lua [Variable]
+```luau [Variable]
(
key: string,
...: any
) -> (...any)
```
-```lua [Example]
+```luau [Example]
local connection = Signal1:Conenct(function(...) return "hey!" end)
local Request = Signal1:Invoke(connection, "Hello World!")
```
@@ -178,7 +178,7 @@ local Request = Signal1:Invoke(connection, "Hello World!")
this use `:Invoke`.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
signal: string,
key: string,
@@ -186,7 +186,7 @@ this use `:Invoke`.
) -> (...any)
```
-```lua [Example]
+```luau [Example]
local connection2 = Signals.Signal2:Conenct(function(...) return "hey!" end)
local Request = Signals.Signal1:Invoke("Signal2", connection2, "Hello World!")
```
diff --git a/docs/api/1.1/buffer.md b/docs/api/1.1/buffer.md
index 5d9bc7f..be79447 100644
--- a/docs/api/1.1/buffer.md
+++ b/docs/api/1.1/buffer.md
@@ -58,13 +58,13 @@ Define strict data schemas for optimized serialization and type safety.
Create a new buffer writer for serializing data.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
capacity: number? -- Optional initial capacity (default: 64)
): Writer
```
-```lua [Example]
+```luau [Example]
local Buffer = Warp.Buffer()
local writer = Buffer.createWriter(256) -- Pre-allocate 256 bytes
```
@@ -75,13 +75,13 @@ local writer = Buffer.createWriter(256) -- Pre-allocate 256 bytes
Build the final buffer for transmission.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
writer: Writer
): buffer -- Returns buffer
```
-```lua [Example]
+```luau [Example]
local Buffer = Warp.Buffer()
local writer = Buffer.createWriter()
@@ -100,13 +100,13 @@ print(buffer.len(finalBuffer))
Build the final buffer with instance references for transmission.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
writer: Writer
): (buffer, { Instance }?) -- Returns buffer and optional instance references
```
-```lua [Example]
+```luau [Example]
local Buffer = Warp.Buffer()
local writer = Buffer.createWriter()
@@ -125,13 +125,13 @@ print(buffer.len(finalBuffer), refs)
Reset a writer for reuse, clearing all data.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
writer: Writer
)
```
-```lua [Example]
+```luau [Example]
local Buffer = Warp.Buffer()
local writer = Buffer.createWriter()
diff --git a/docs/api/1.1/client.md b/docs/api/1.1/client.md
index d0e508e..0acaad1 100644
--- a/docs/api/1.1/client.md
+++ b/docs/api/1.1/client.md
@@ -13,14 +13,14 @@ local Client = Warp.Client()
Connect to an event to receive incoming data from the server.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
fn: (...any) -> ...any
) -> Connection
```
-```lua [Example]
+```luau [Example]
local connection = Client.Connect("ServerNotify", function(message, sender)
print(`Server message from {sender}: {message}`)
end)
@@ -33,14 +33,14 @@ print(connection.Connected)
Similar to `:Connect` but automatically disconnects after the first firing.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
fn: (...any) -> ...any
) -> Connection
```
-```lua [Example]
+```luau [Example]
Client.Once("WelcomeMessage", function(welcomeText)
print(`Welcome: {welcomeText}`)
end)
@@ -52,13 +52,13 @@ end)
Wait for an event to be triggered.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string
) -> (number, ...any)
```
-```lua [Example]
+```luau [Example]
local elapsed, message = Client.Wait("ServerMessage")
print(`Received message after {elapsed} seconds: {message}`)
```
@@ -69,11 +69,11 @@ print(`Received message after {elapsed} seconds: {message}`)
Disconnect the event connection.
::: code-group
-```lua [Variable]
+```luau [Variable]
()
```
-```lua [Example]
+```luau [Example]
local connection = Client.Connect("ServerNotify", function(message, sender)
print(`Server message from {sender}: {message}`)
-- Disconnect the connection
@@ -88,13 +88,13 @@ print(Connection.Connected)
Disconnect all connections for a specific event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string
)
```
-```lua [Example]
+```luau [Example]
Client.DisconnectAll("ServerNotify")
```
:::
@@ -104,13 +104,13 @@ Client.DisconnectAll("ServerNotify")
Disconnect all connections and remove the event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string
)
```
-```lua [Example]
+```luau [Example]
Client.Destroy("ServerNotify")
```
:::
@@ -120,7 +120,7 @@ Client.Destroy("ServerNotify")
Fire an event to the server.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
reliable: boolean,
@@ -128,7 +128,7 @@ Fire an event to the server.
)
```
-```lua [Example]
+```luau [Example]
-- (TCP) Reliable event (guaranteed delivery)
Client.Fire("PlayerAction", true, "jump", playerPosition)
@@ -142,7 +142,7 @@ Client.Fire("PositionUpdate", false, currentPosition)
Invoke the server with timeout support.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
timeout: number?,
@@ -150,7 +150,7 @@ Invoke the server with timeout support.
) -> ...any
```
-```lua [Example]
+```luau [Example]
local Client = Warp.Client()
local response = Client.Invoke("RequestData", 3, "playerStats")
if response then
@@ -170,14 +170,14 @@ This function is yielded. Returns `nil` if timeout occurs.
Define a schema for strict data packing on a specific event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
schema: Buffer.SchemaType
)
```
-```lua [Example]
+```luau [Example]
local Client = Warp.Client()
-- Define a schema for position updates
diff --git a/docs/api/1.1/server.md b/docs/api/1.1/server.md
index a8a12ac..50e2123 100644
--- a/docs/api/1.1/server.md
+++ b/docs/api/1.1/server.md
@@ -13,14 +13,14 @@ local Server = Warp.Server()
Connect to an event to receive incoming data from clients.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
fn: (player: Player, ...any) -> ...any
) -> Connection
```
-```lua [Example]
+```luau [Example]
local connection = Server.Connect("ServerNotify", function(player, message)
print(`Client message from {player}: {message}`)
end)
@@ -33,14 +33,14 @@ print(connection.Connected)
Similar to `:Connect` but automatically disconnects after the first firing.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
fn: (player: Player, ...any) -> ...any
) -> Connection
```
-```lua [Example]
+```luau [Example]
Server.Once("WelcomeMessage", function(welcomeText)
print(`Welcome: {welcomeText}`)
end)
@@ -52,13 +52,13 @@ end)
Wait for an event to be triggered.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string
) -> (number, ...any)
```
-```lua [Example]
+```luau [Example]
local elapsed, message = Server.Wait("ServerMessage")
print(`Received message after {elapsed} seconds: {message}`)
```
@@ -69,13 +69,13 @@ print(`Received message after {elapsed} seconds: {message}`)
Disconnect all connections for a specific event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string
)
```
-```lua [Example]
+```luau [Example]
Server.DisconnectAll("ServerNotify")
```
:::
@@ -85,13 +85,13 @@ Server.DisconnectAll("ServerNotify")
Disconnect all connections and remove the event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string
)
```
-```lua [Example]
+```luau [Example]
Server.Destroy("ServerNotify")
```
:::
@@ -101,7 +101,7 @@ Server.Destroy("ServerNotify")
Fire an event to a specific player.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
reliable: boolean,
@@ -110,7 +110,7 @@ Fire an event to a specific player.
)
```
-```lua [Example]
+```luau [Example]
Server.Fire("ServerNotify", true, player, "Hello from server!")
```
:::
@@ -120,7 +120,7 @@ Server.Fire("ServerNotify", true, player, "Hello from server!")
Fire an event to all connected players.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
reliable: boolean,
@@ -128,7 +128,7 @@ Fire an event to all connected players.
)
```
-```lua [Example]
+```luau [Example]
Server.Fires("Broadcast", true, "Server announcement!")
```
:::
@@ -138,7 +138,7 @@ Server.Fires("Broadcast", true, "Server announcement!")
Fire an event to all players except specified ones.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
reliable: boolean,
@@ -147,7 +147,7 @@ Fire an event to all players except specified ones.
)
```
-```lua [Example]
+```luau [Example]
local excludedPlayers = { player1, player2 }
Server.FireExcept("Update", true, excludedPlayers, "Game update")
```
@@ -158,7 +158,7 @@ Server.FireExcept("Update", true, excludedPlayers, "Game update")
Invoke a client with timeout support.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
player: Player,
@@ -167,7 +167,7 @@ Invoke a client with timeout support.
) -> ...any
```
-```lua [Example]
+```luau [Example]
local response = Server.Invoke("RequestData", player, 3, "userInfo")
if response then
print("Client responded:", response)
@@ -186,14 +186,14 @@ This function is yielded. Returns `nil` if timeout occurs.
Define a schema for strict data packing on a specific event.
::: code-group
-```lua [Variable]
+```luau [Variable]
(
remoteName: string,
schema: Buffer.SchemaType
)
```
-```lua [Example]
+```luau [Example]
local Server = Warp.Server()
local dataSchema = Server.Schema.struct({
diff --git a/docs/guide/example.md b/docs/guide/example.md
index bc24563..ed60f6c 100644
--- a/docs/guide/example.md
+++ b/docs/guide/example.md
@@ -1,71 +1,76 @@
-# Example
+# Example
Let's try and play something with Warp!
::: code-group
-```lua [Server]
-local Warp = require("path.to.module")
+```luau [Schemas]
+local Schema = require(path.to.warp).Buffer.Schema
--- Events
-local Example = Warp.Server("Example")
-local Ping = Warp.Server("Ping")
-local Pong = Warp.Server("Pong")
-local PingAll = Warp.Server("PingAll")
+return {
+ Example = Schema.array(Schema.string()),
+ Ping = Schema.string(),
+ Pong = Schema.string(),
+ PingAll = Schema.string(),
+}
+```
+```luau [Server]
+local Warp = require(path.to.warp).Server()
+local Schemas = require(path.to.schemas)
-Example:Connect(function(player, arg1, arg2)
- print(arg1, arg2)
- return "Whooo!"
+-- Use schemas
+for eventName, schema in Schemas do
+ Warp.useSchema(eventName, schema)
+end
+
+Warp.Connect("Example", function(player, arg)
+ print(table.unpack(arg))
+ return "Hey!"
end)
-
-Ping:Connect(function(player, ping)
+Warp.Connect("Ping", function(player, ping)
if ping then
print("PING!")
- Pong:Fire(true, player, "pong!")
- PingAll:Fires(true, "ey!")
+ Warp.Fire("Pong", true, player, "pong!") -- Fire to spesific player through reliable event
+ Warp.Fire("PingAll", true, "ey!") -- Fire to all clients through reliable event
end
end)
```
-```lua [Client]
+```luau [Client]
local Players = game:GetService("Players")
-local Warp = require("path.to.module")
+local Warp = require(path.to.warp).Client()
+local Schemas = require(path.to.schemas)
--- Events
-local Example = Warp.Client("Example")
-local Ping = Warp.Client("Ping")
-local Pong = Warp.Client("Pong")
-local PingAll = Warp.Client("PingAll")
+-- Use schemas
+for eventName, schema in Schemas do
+ Warp.useSchema(eventName, schema)
+end
-- Connect the events
local connection1
-connection1 = Pong:Connect(function(pong: boolean)
+connection1 = Warp.Connect("Pong", function(pong: boolean) -- we store the connection so we can disconnect it later
if pong then
print("PONG!")
end
end)
-
-PingAll:Connect(function(isPing: boolean)
+Warp.Connect("PingAll", function(isPing: boolean)
if isPing then
print("I GET PINGED!")
end
end)
-- Try request a event from server!
-print(Example:Invoke(5, "Hello!", "this is from > "..Players.LocalPlayer.Name))
+print(Warp.Invoke("Example", 1, { "Hello!", `this is from: @{Players.LocalPlayer.Name}` }))
-- Do a ping & pong to server!
-Ping:Fire(true, "ping!")
+Warp.Fire("Ping", true, "ping!") -- we send through reliable event
task.wait(1) -- lets wait 1 seconds!
-- Disconnect All the events
-Pong:DisconnectAll()
-PingAll:DisconnectAll()
--- or Just disconnect spesific connection
-Pong:Disconnect(connection1)
+connection1:DisconnectAll()
+-- or just disconnect spesific connection
+Warp.Disconnect("PingAll")
-- Destroying/Deleting a Event?
-Pong:Destroy()
-
--- Yay Done!
+Warp.Destroy("Pong")
```
:::
\ No newline at end of file