--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
Knit wasn’t discontinued just because sleitnick didn’t want to update it anymore, it was due to the lack of intellisense and general lack of need for these types of frameworks. A simple module service & controller architecture will outperform this framework and any other Knit related framework.