diff options
Diffstat (limited to 'client/application.go')
| -rw-r--r-- | client/application.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/client/application.go b/client/application.go index eb72d14..d396f24 100644 --- a/client/application.go +++ b/client/application.go @@ -78,11 +78,20 @@ func (a *application) OnEvent(cmd proto.Command) { } case "delete": a.cache.Gone(cmd.Target) + fallthrough + case "leave": cl := channelLocation {id: cmd.Target} - if a.windowCache.Get(cl) != nil { - a.windowCache.Evict(cl) - a.removeFromHistory(cl) + w := a.windowCache.Get(cl) + if w != nil { + w.(*channelWindow).onLeaveChannel() } + a.channelList.remove(cl) + case "join": + a.cache.Fetch(cmd.Target, func(ch *proto.Object) { + if ch != nil { + a.newChannel(*ch) + } + }) } } @@ -103,11 +112,8 @@ func (a *application) OnResponse(requestId string, cmd proto.Command) { if len(cmd.Args) > 0 { a.cmdWindow.info("your name is: %s", cmd.Args[0].Fields[""]) } - case "p": - if len(cmd.Args) > 0 { - a.onPut(cmd.Target, cmd.Args[0]) - } } + a.OnEvent(cmd) } func (a *application) onUpdate(target string, update proto.Object) { @@ -248,6 +254,7 @@ func (a *application) join(channelName string) { case *channelWindow: w.(*channelWindow).endOfHistory = false } + a.goTo(channelLocation {id: ch.Id}) case "fail": if len(response.Args) > 0 { f := proto.Fail(response.Args[0]) @@ -283,6 +290,7 @@ func (a *application) createChannel(name string) { case "create": if len(response.Args) > 0 { a.newChannel(response.Args[0]) + a.goTo(channelLocation {id: response.Args[0].Id}) } case "fail": if len(response.Args) > 0 { |
