I’m working on a modular item system, where the client and server creates their own OOP object. However i’m having networking issues. I don’t want to have to hardcode in events into the ItemService. Knit cannot create new remote events during runtime. How can I keep my modular item system and allow for networking between the client and server modules of the system?
I’ve been using this, however this is only a one way connection, and I worry about its security.
You can use signals with Knit to send remote events.
--[[ Client ]]--
local Knit = require(game:GetService("ReplicatedStorage").Packages.Knit)
local ItemService = Knit:GetService("ItemService")
ItemService.SomeEvent:Connect(function(msg)
print(msg)
end)
--[[ Server ]]--
local Signal = require(Knit.Util.Signal)
local ItemService = Knit.CreateService {
Name = "MyService",
Client= {
SomeEvent = Signal.new(),
}
}
function ItemService.Test()
ItemService.Client.SomeEvent:Fire("test")
end
return MyService
It’s been a good year since I’ve used Knit, so I’m sorry if my syntax is a bit rusty.
My issue is that you cannot create signals after knit has been started, and i’m using classes that aren’t being instanced until they exist, which is always after knit starts.
"Events and methods should never be added to a service's Client table after Knit.Start() has been called"
I’m using OOP to create custom classes. I need the client/server to update values such as ammo. The classes aren’t created until after knit is started because a knit service is the module that calls/creates them.