diff --git a/.gitignore b/.gitignore index b31d724..f1c3f64 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ /ProjectWIND /data **/.DS_Store -/app_demo/ \ No newline at end of file +/app_demo/ +.idea/ +.vscode/ \ No newline at end of file diff --git a/core/api.go b/core/api.go index c072f24..7857e1b 100644 --- a/core/api.go +++ b/core/api.go @@ -359,7 +359,11 @@ func (a *apiInfo) SetGroupAddRequest(flag string, subType string, approve bool, return } -// 2.有响应API,使用http协议处理 +// 2.有响应API,需添加echo字段 + +func (a *apiInfo) GetLoginInfo(flag string, approve bool) { + +} var AppApi apiInfo diff --git a/core/web_socket.go b/core/web_socket.go index 0b9bdcd..846e99d 100644 --- a/core/web_socket.go +++ b/core/web_socket.go @@ -115,6 +115,26 @@ func processMessage(messageType int, message []byte) { } default: { + messageMap := make(map[string]interface{}) + err := json.Unmarshal(message, &messageMap) + if err != nil { + LOG.ERROR("Unmarshal error when handling api response message: %v", err) + return + } + if messageMap["status"] != "ok" { + LOG.ERROR("API response error: %v", messageMap["status"]) + return + } + if messageMap["echo"] == "" { + LOG.WARN("Unknown API response: %v", messageMap["echo"]) + return + } + apiResp := make(map[string]interface{}) + apiResp["uuid"] = messageMap["echo"] + ApiChan := make(chan map[string]interface{}) + go func(apiResp map[string]interface{}) { + ApiChan <- apiResp + }(apiResp) // 此处为api请求响应数据,通过channel返回给调用者 return } diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..9ef6c8a --- /dev/null +++ b/doc/index.html @@ -0,0 +1,25 @@ + + +
+ + +