diff options
Diffstat (limited to 'server/object/object.go')
| -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 +} |
