aboutsummaryrefslogtreecommitdiff
path: root/connector/external/external.go
diff options
context:
space:
mode:
Diffstat (limited to 'connector/external/external.go')
-rw-r--r--connector/external/external.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/connector/external/external.go b/connector/external/external.go
index c40d55b..9aae0f1 100644
--- a/connector/external/external.go
+++ b/connector/external/external.go
@@ -54,6 +54,7 @@ const (
CLOSE = "close"
// external -> ezbr
+ SAVE_CONFIG = "save_config"
JOINED = "joined"
LEFT = "left"
USER_INFO_UPDATED = "user_info_updated"
@@ -198,6 +199,16 @@ func (m *extMessageWithData) UnmarshalJSON(jj []byte) error {
}
*m = extMessageWithData{extMessage: c}
switch c.MsgType {
+ case SAVE_CONFIG:
+ var cf struct {
+ Data Configuration `json:"data"`
+ }
+ err := json.Unmarshal(jj, &cf)
+ if err != nil {
+ return err
+ }
+ m.Data = cf.Data
+ return nil
case USER_INFO_UPDATED:
var ui struct {
Data UserInfo `json:"data"`
@@ -229,14 +240,14 @@ func (m *extMessageWithData) UnmarshalJSON(jj []byte) error {
m.Data = &ev.Data
return nil
case REP_SEARCH_RESULTS:
- var ev struct {
+ var sr struct {
Data []UserSearchResult `json:"data"`
}
- err := json.Unmarshal(jj, &ev)
+ err := json.Unmarshal(jj, &sr)
if err != nil {
return err
}
- m.Data = ev.Data
+ m.Data = sr.Data
return nil
case JOINED, LEFT, CACHE_PUT, CACHE_GET, REP_OK, REP_ERROR:
return nil
@@ -364,6 +375,8 @@ func (ext *External) Close() {
func (ext *External) handleCmd(msg *extMessageWithData) {
switch msg.MsgType {
+ case SAVE_CONFIG:
+ ext.handler.SaveConfig(msg.Data.(Configuration))
case JOINED:
ext.handler.Joined(msg.Room)
case LEFT: