import{_ as s,o as a,c as n,Q as l}from"./chunks/framework.419948d5.js";const u=JSON.parse('{"title":"Server","description":"","frontmatter":{},"headers":[],"relativePath":"api/1.0/server.md","filePath":"api/1.0/server.md"}'),e={name:"api/1.0/server.md"},o=l(`
A Server-sided Connection
.new
Create new FastNet2 event
(
Identifier: string
)
(
Identifier: string
)
Identifier will converte/encode into hash identifier
local Remote = FastNet2.new("Remote")
local Remote = FastNet2.new("Remote")
:Connect
or :Listen
Listen an event from the server to receive, :Connect
and :Listen
is the same function.
(
callback: (...any) -> ()
)
(
callback: (...any) -> ()
)
Each event only allowed have one callback.
Remote:Connect(function(...)
print(...)
end)
Remote:Connect(function(...)
print(...)
end)
to know if the event is connected or not by doing .Connected
print(Remote.Connected)
print(Remote.Connected)
:Disconnect
Disconnect the event
Remote:Disconnect()
Remote:Disconnect()
:Fire
Fire the event to the spesific client with data.
(
player: Player,
...: any
)
(
player: Player,
...: any
)
Remote:Fire(player, "Hello World!")
Remote:Fire(player, "Hello World!")
WARNING
This function have rate limiting to prevent spamming
:Fires
Fire the event to all clients with data.
(
...: any
)
(
...: any
)
Remote:Fires("Hello World!")
Remote:Fires("Hello World!")
WARNING
This function have rate limiting to prevent spamming
:Pull
Pull is a function that invoke to server.
(
timeout: number,
player: Player,
...: any
) -> (...any)
(
timeout: number,
player: Player,
...: any
) -> (...any)
local Request = Remote:Pull(2, player, "Hello World!")
local Request = Remote:Pull(2, player, "Hello World!")
WARNING
This function is yielded, and the minimum for timeout is 2 (seconds)
:Wait
Wait the event that triggered/pinged
Remote:Wait()
Remote:Wait()
WARNING
This function is yielded
:Destroy
Disconnect the event and Remove the event from FastNet2
Remote:Destroy()
Remote:Destroy()