CradleServer
This is the API Documentation for the Cradle module. It contains all the API functions for the server.
local Cradle = require(game:GetService("ReplicatedStorage").Cradle)
Properties
RemoteComm
CradleServer.RemoteComm:
table
Contains the Remote Communication Module.
tip
See the Networking guide to learn more about it.
Component
CradleServer.Component:
table
Contains the Component Module.
tip
See the Components guide to learn more about it.
Modules
CradleServer.Modules:
table
Contains all modules in the Modules folder.
Shared
CradleServer.Shared:
table
Contains all modules that is stored in the Modules Folder.
Packages
CradleServer.Packages:
table
Contains all modules in the Packages folder.
Util
This was deprecated in v1.0.0
This item is deprecated. Do not use it for new work.
CradleServer.Util:
table
Contains all modules in the Packages folder.
Functions
RegisterMiddleware
CradleServer:
RegisterMiddleware
(
priority:
number
,
function:
func
,
services:
table?
) →
nil
Registers a middleware function to be called before a service's remote object is invoked.
caution
This will only run when the server has received a request from the client.
Usage
CradleServer:RegisterMiddleware(1, function()
print("This is a middleware function")
end, {
Cradle:GetService("SomeService"),
Cradle:GetService("AnotherService"),
})
CreateService
CradleServer:
CreateService
(
Name:
string
,
Client:
table
) →
Service
Creates a new service.
caution
Services must be created before calling Cradle:Start()
Usage
local SomeService = Cradle:CreateService({
Name = "SomeService",
Client = {},
})
function SomeService.Client:SomeRemoteFunction()
print("SomeService has been called!")
return "Hello from the server!"
end
function SomeService:Init()
print("SomeService has been initialised!")
end
function SomeService:Start()
print("SomeService has started!")
end
GetService
CradleServer:
GetService
(
serviceName:
string
) →
Service
Gets a service by name. Throws a warning if the service is not found.
Load
CradleServer:
Load
(
) →
nil
Loads all services and components.
caution
This must be called before calling Cradle:Start()
Start
CradleServer:
Start
(
) →
nil
Starts all services and components.
caution
This must be called after calling Cradle:Load()