You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--Server RuntimelocalKernel=require(game:GetService("ReplicatedStorage").Kernel)
Kernel.SetServiceFolder(script.Services) --where will the services be taken fromKernel.AddMiddleware(function(context, ...)
print(string.format("[middleware] %s: %s.%s", context.Player.Name, context.Service, context.Method))
returntrueend)
Kernel.Start()
Client Side Runtime
--Client RuntimelocalKernel=require(game:GetService("ReplicatedStorage").Kernel)
Kernel.SetControllerFolder(script.Controllers) --where will the controllers be taken fromKernel.Start()
Service & Controller Sides
--Test ServicelocalKernel=require(game.ReplicatedStorage.Kernel)
localTestService=Kernel.CreateService({
Name="TestService",
Client= {
ping=Kernel.RemoteSignal(),
hi=function(self, player: Player)
return"hello: "..player.Nameend,
},
})
functionTestService:KernelInit()
print("im first started in server")
self.Client.ping:Connect(function(player)
print("ping", player.Name)
self.Client.ping:Fire(player, "pong!")
end)
endfunctionTestService:KernelStart()
print("im second started")
endreturnTestService
--Test ControllerlocalKernel=require(game.ReplicatedStorage.Kernel)
localTestController=Kernel.CreateController({
Name="TestController",
})
functionTestController:KernelInit()
print("im first started in client")
localTestService=Kernel.GetService("TestService")
TestService.ping:Connect(function(msg)
print("msg:", msg)
end)
endfunctionTestController:KernelStart()
print("im second started in client")
localTestService=Kernel.GetService("TestService")
print("Test controller server said:", TestService:hi())
TestService.ping:Fire()
endreturnTestController