--Server Runtime
local Kernel = require(game:GetService("ReplicatedStorage").Kernel)
Kernel.SetServiceFolder(script.Services) --where will the services be taken from
Kernel.AddMiddleware(function(context, ...)
print(string.format("[middleware] %s: %s.%s", context.Player.Name, context.Service, context.Method))
return true
end)
Kernel.Start()
Client Side Runtime
--Client Runtime
local Kernel = require(game:GetService("ReplicatedStorage").Kernel)
Kernel.SetControllerFolder(script.Controllers) --where will the controllers be taken from
Kernel.Start()
Service & Controller Sides
--Test Service
local Kernel = require(game.ReplicatedStorage.Kernel)
local TestService = Kernel.CreateService({
Name = "TestService",
Client = {
ping = Kernel.RemoteSignal(),
hi = function(self, player: Player)
return "hello: "..player.Name
end,
},
})
function TestService:KernelInit()
print("im first started in server")
self.Client.ping:Connect(function(player)
print("ping", player.Name)
self.Client.ping:Fire(player, "pong!")
end)
end
function TestService:KernelStart()
print("im second started")
end
return TestService
--Test Controller
local Kernel = require(game.ReplicatedStorage.Kernel)
local TestController = Kernel.CreateController({
Name = "TestController",
})
function TestController:KernelInit()
print("im first started in client")
local TestService = Kernel.GetService("TestService")
TestService.ping:Connect(function(msg)
print("msg:", msg)
end)
end
function TestController:KernelStart()
print("im second started in client")
local TestService = Kernel.GetService("TestService")
print("Test controller server said:", TestService:hi())
TestService.ping:Fire()
end
return TestController
Nothing is better than just using modules as provided by roblox, you get intellisense, you can use your own networking module if you wanted, and youâre not forced to a pattern
Intellisense is the auto complete for variables and such. For example, Tween: , a dropdown pops up with options such as :Play(), :Create(), :Cancel() and such.
even if you added type checking, every time you make a new âserviceâ or âcontrollerâ or anything that is loaded dynamically you wonât have intellisense. itâs one of many reasons why itâs discontinued
it seems like op just saw Knit was archived and wanted to make his own rendition of it without understanding why Knit was archived in the first place