From 10b8a79389e7073f6bd65695c3d05c77b825bc33 Mon Sep 17 00:00:00 2001 From: citrons Date: Sun, 26 Jan 2025 01:56:53 -0600 Subject: initial commit --- server/object/object.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 server/object/object.go (limited to 'server/object/object.go') diff --git a/server/object/object.go b/server/object/object.go new file mode 100644 index 0000000..d18507c --- /dev/null +++ b/server/object/object.go @@ -0,0 +1,36 @@ +package object + +import ( + "citrons.xyz/talk/proto" + "citrons.xyz/talk/server/session" +) + +type Object interface { + SendRequest(session.Request) +} + +type World struct { + objects map[string]Object +} + +func NewWorld() *World { + return &World {make(map[string]Object)} +} + +func (w *World) GetObject(id string) Object { + return w.objects[id] +} + +func (w *World) PutObject(id string, o Object) { + w.objects[id] = o +} + +func (w *World) RemoveObject(id string) { + w.objects[id] = nil +} + +func (w *World) NewObject(o Object) string { + id := proto.GenId() + w.PutObject(id, o) + return id +} -- cgit v1.2.3