aboutsummaryrefslogtreecommitdiff
path: root/connector/external
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-03-09 18:02:13 +0100
committerAlex Auvolat <alex@adnab.me>2020-03-09 18:02:13 +0100
commit7c39436eda59efb033d172dfa03af3782f0acacf (patch)
tree907549515b8dc61dd55fa728a8620b3c92fd8c0a /connector/external
parentf9e0c58f3c0e90b987b7763f020ea5dcbf366779 (diff)
downloadeasybridge-7c39436eda59efb033d172dfa03af3782f0acacf.tar.gz
easybridge-7c39436eda59efb033d172dfa03af3782f0acacf.zip
Save client pickle automatically (messenger)
Diffstat (limited to 'connector/external')
-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: