Working on major restructuring

This commit is contained in:
2025-12-20 15:30:24 -07:00
parent f4c5ba1f14
commit 645a47b98a
53 changed files with 226 additions and 1407 deletions
+61
View File
@@ -0,0 +1,61 @@
module GameServer
module Server
class MessageRouter
def initialize(world)
@world = world
end
def handle(data)
case data["type"]
when "hello"
hello
when "query"
query(data)
when "command"
command(data)
else
error("UNKNOWN_TYPE")
end
end
def hello
{
type: "update",
domain: "world",
payload: {
time: @world.time,
game_speed: Settings::GAME_SPEED
}
}
end
def query(data)
if data["domain"] == "player"
{
type: "update",
domain: "player",
payload: { money: 1000 }
}
else
error("UNKNOWN_DOMAIN")
end
end
def command(data)
{
type: "update",
domain: "command",
payload: { status: "accepted" }
}
end
def error(code)
{
type: "error",
domain: "system",
payload: { code: code }
}
end
end
end
end