diff options
| author | citrons <citrons@mondecitronne.com> | 2025-01-26 01:56:53 -0600 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-01-26 01:56:53 -0600 |
| commit | 10b8a79389e7073f6bd65695c3d05c77b825bc33 (patch) | |
| tree | b7e6dbd84b5b2c960ab8aafc1f99c3950d679e44 /server/object | |
initial commit
Diffstat (limited to 'server/object')
| -rw-r--r-- | server/object/object.go | 36 |
1 files changed, 36 insertions, 0 deletions
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 +} |
