networkClient
This item only works when running on the client. Client
The client counterpart of network.
Properties
ClientRemoteProperty
Read onlynetworkClient.ClientRemoteProperty:
ClientRemoteProperty
ClientRemoteSignal
Read onlynetworkClient.ClientRemoteSignal:
ClientRemoteSignal
Functions
allFromParent
Returns an array of all networks dispatched to parent
.
-- Server
local Workspace = game:GetService("Workspace")
local network1 = network.Server.new("Test1", Workspace)
network1:append("status", "not good mate")
network1:dispatch(Workspace)
local network2 = network.Server.new("Test2", Workspace)
network2:append("status", "good mate!")
network2:dispatch(Workspace)
-- Client
local Workspace = game:GetService("Workspace")
for _, networkObject in Network.client.fromParent(Workspace) do
print(networkObject.status)
end
--> "not good mate"
--> "good mate!"
fromParent
networkClient.
fromParent
(
) →
Promise
<
DispatchedNetwork:
{
[
string
]
:
any
}
>
Returns a promise which is resolved once a network with the
name of name
, is dispatched to parent
. If a network with the name of name
is already dispatched to
parent
, the promise will immediately resolve.
For e.g:
-- Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local network = require(ReplicatedStorage.Packages.network)
local testNetwork = Network.Server.new("Test")
testNetwork:append("method", function(player)
return string.format("hi, %s!", player.Name)
end)
-- Dispatch the network to workspace:
testNetwork:dispatch(Workspace)
-- Client
local Workspace = game:GetService("Workspace")
-- Get the network of name "Test", dispatched to workspace
local testNetwork = network.client.fromParent("Test", Workspace):expect()
print(testNetwork.method()) --> "hi, bubshurb!"
You can also pass in timeout
which will result in the promise to be rejected (if it hasn't resolved in time).
timeout
will default to 20
seconds.