diff options
Diffstat (limited to 'server/channel')
| -rw-r--r-- | server/channel/channel.go | 19 | ||||
| -rw-r--r-- | server/channel/command.go | 17 |
2 files changed, 35 insertions, 1 deletions
diff --git a/server/channel/channel.go b/server/channel/channel.go index 50b43b6..9a3134e 100644 --- a/server/channel/channel.go +++ b/server/channel/channel.go @@ -10,6 +10,7 @@ import ( type ChannelStore struct { world *object.World byName map[string]*Channel + deleted map[string]Tombstone } type Channel struct { @@ -23,8 +24,14 @@ type Channel struct { Stream session.Stream } +type Tombstone struct { + name string +} + func NewStore(world *object.World) *ChannelStore { - return &ChannelStore {world, make(map[string]*Channel)} + return &ChannelStore { + world, make(map[string]*Channel), make(map[string]Tombstone), + } } func (cs *ChannelStore) CreateChannel(name string) (*Channel, *proto.Fail) { @@ -139,6 +146,10 @@ func (c *Channel) Delete() { } delete(c.store.byName, c.name) c.store.world.RemoveObject(c.id) + + deleted := Tombstone {c.name} + c.store.deleted[c.id] = deleted + c.store.world.PutObject(c.id, deleted) } func (c *Channel) GetInfo() proto.Object { @@ -146,3 +157,9 @@ func (c *Channel) GetInfo() proto.Object { "channel", c.id, map[string]string {"": c.name}, } } + +func (t Tombstone) GetInfo() proto.Object { + return proto.Object { + "deleted", "", map[string]string {"": t.name}, + } +} diff --git a/server/channel/command.go b/server/channel/command.go index 94cf38f..5190efe 100644 --- a/server/channel/command.go +++ b/server/channel/command.go @@ -251,3 +251,20 @@ func (c *Channel) SendRequest(r session.Request) { r.ReplyInvalid() } } + +func (t Tombstone) SendRequest(r session.Request) { + switch r.Cmd.Kind { + + case "update": + r.Reply(proto.Fail{"bad-target", "", nil}.Cmd()) + + case "i", "s": + r.Reply(proto.NewCmd("i", "", t.GetInfo())) + + case "u": + r.ReplyOk() + + default: + r.ReplyInvalid() + } +} |
