diff --git a/main.go b/main.go index e7a1dea..2f989a8 100644 --- a/main.go +++ b/main.go @@ -81,6 +81,29 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru // Loop hub connection + serveUserInfo := func(nick string) { + props := "" + hub.Users(func(users *map[string]libnmdc.UserInfo) error { + uinfo, ok := (*users)[nick] + if !ok { + return nil // just skip + } + + bProps, err := json.Marshal(uinfo) + if err != nil { + return nil // just skip + } + + props = string(bProps) + return nil + }) + + // 'Message' is a json-encoded param with user properties + if len(props) > 0 { + so.Emit("info", UserMessageStruct{User: nick, Message: props}) + } + } + for { select { @@ -100,8 +123,12 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru case libnmdc.EVENT_PRIVATE: so.Emit("priv", UserMessageStruct{User: hev.Nick, Message: hev.Message}) + case libnmdc.EVENT_USER_UPDATED_INFO: + serveUserInfo(hev.Nick) + case libnmdc.EVENT_USER_JOINED: so.Emit("join", UserMessageStruct{User: hev.Nick}) + serveUserInfo(hev.Nick) case libnmdc.EVENT_USER_PART: so.Emit("part", UserMessageStruct{User: hev.Nick})