forked from openimsdk/openim-sdk-core
/
ws_work_moments.go
53 lines (45 loc) · 2.04 KB
/
ws_work_moments.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package ws_local_server
import (
"encoding/json"
"github.com/erbaner/be-core/open_im_sdk"
"github.com/erbaner/be-core/pkg/log"
"github.com/erbaner/be-core/pkg/utils"
)
type WorkMomentsCallback struct {
uid string
}
func (wsRouter *WsFuncRouter) SetWorkMomentsListener() {
var cb WorkMomentsCallback
cb.uid = wsRouter.uId
userWorker := open_im_sdk.GetUserWorker(wsRouter.uId)
userWorker.SetWorkMomentsListener(&cb)
}
func (w *WorkMomentsCallback) OnRecvNewNotification() {
SendOneUserMessage(EventData{cleanUpfuncName(runFuncName()), 0, "", "", "0"}, w.uid)
}
func (wsRouter *WsFuncRouter) GetWorkMomentsUnReadCount(input, operationID string) {
userWorker := open_im_sdk.GetUserWorker(wsRouter.uId)
if !wsRouter.checkResourceLoadingAndKeysIn(userWorker, input, operationID, runFuncName(), nil) {
return
}
userWorker.WorkMoments().GetWorkMomentsUnReadCount(&BaseSuccessFailed{runFuncName(), operationID, wsRouter.uId}, operationID)
}
func (wsRouter *WsFuncRouter) GetWorkMomentsNotification(input, operationID string) {
m := make(map[string]interface{})
if err := json.Unmarshal([]byte(input), &m); err != nil {
log.Info(operationID, utils.GetSelfFuncName(), "unmarshal failed", input, err.Error())
wsRouter.GlobalSendMessage(EventData{cleanUpfuncName(runFuncName()), StatusBadParameter, "unmarshal failed", "", operationID})
}
userWorker := open_im_sdk.GetUserWorker(wsRouter.uId)
if !wsRouter.checkResourceLoadingAndKeysIn(userWorker, input, operationID, runFuncName(), nil) {
return
}
userWorker.WorkMoments().GetWorkMomentsNotification(&BaseSuccessFailed{runFuncName(), operationID, wsRouter.uId}, int(m["offset"].(float64)), int(m["count"].(float64)), operationID)
}
func (wsRouter *WsFuncRouter) ClearWorkMomentsNotification(input, operationID string) {
userWorker := open_im_sdk.GetUserWorker(wsRouter.uId)
if !wsRouter.checkResourceLoadingAndKeysIn(userWorker, input, operationID, runFuncName(), nil) {
return
}
userWorker.WorkMoments().ClearWorkMomentsNotification(&BaseSuccessFailed{runFuncName(), operationID, wsRouter.uId}, operationID)
}