Skip to content

Commit

Permalink
Bug/fix offline recv message (openimsdk#416)
Browse files Browse the repository at this point in the history
* fix: wasm createLocationMessage support float64 and trigger OnRecvOfflineNewMessage when android app running in the background.

Signed-off-by: Gordon <[email protected]>

* fix: wasm createLocationMessage support float64 and trigger OnRecvOfflineNewMessage when android app running in the background.

Signed-off-by: Gordon <[email protected]>

---------

Signed-off-by: Gordon <[email protected]>
  • Loading branch information
FGadvancer committed Nov 20, 2023
1 parent fce8c00 commit cff6f9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/conversation_msg/conversation_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ func isContainRevokedList(target string, List []*sdk_struct.MessageRevoked) (boo

func (c *Conversation) newMessage(ctx context.Context, newMessagesList sdk_struct.NewMsgList, cc, nc map[string]*model_struct.LocalConversation) {
sort.Sort(newMessagesList)
if c.IsBackground.Load() {
if c.GetBackground() {
u, err := c.user.GetSelfUserInfo(ctx)
if err != nil {
log.ZWarn(ctx, "GetSelfUserInfo err", err)
Expand Down
19 changes: 14 additions & 5 deletions internal/interaction/long_conn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"strconv"
"strings"
"sync"
"sync/atomic"
"time"

"github.com/OpenIMSDK/protocol/sdkws"
Expand Down Expand Up @@ -94,7 +93,9 @@ type LongConnMgr struct {
Syncer *WsRespAsyn
encoder Encoder
compressor Compressor
IsBackground atomic.Bool

mutex sync.Mutex
IsBackground bool
// write conn lock
connWrite *sync.Mutex
}
Expand Down Expand Up @@ -489,8 +490,9 @@ func (c *LongConnMgr) reConn(ctx context.Context, num *int) (needRecon bool, err
c.w.Lock()
c.connStatus = Connecting
c.w.Unlock()
url := fmt.Sprintf("%s?sendID=%s&token=%s&platformID=%d&operationID=%s&isBackground=%t", ccontext.Info(ctx).WsAddr(),
ccontext.Info(ctx).UserID(), ccontext.Info(ctx).Token(), ccontext.Info(ctx).PlatformID(), ccontext.Info(ctx).OperationID(), c.IsBackground.Load())
url := fmt.Sprintf("%s?sendID=%s&token=%s&platformID=%d&operationID=%s&isBackground=%t",
ccontext.Info(ctx).WsAddr(), ccontext.Info(ctx).UserID(), ccontext.Info(ctx).Token(),
ccontext.Info(ctx).PlatformID(), ccontext.Info(ctx).OperationID(), c.GetBackground())
if c.IsCompression {
url += fmt.Sprintf("&compression=%s", "gzip")
}
Expand Down Expand Up @@ -565,6 +567,13 @@ func (c *LongConnMgr) Close(ctx context.Context) {
}

}
func (c *LongConnMgr) GetBackground() bool {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.IsBackground
}
func (c *LongConnMgr) SetBackground(isBackground bool) {
c.IsBackground.Store(isBackground)
c.mutex.Lock()
defer c.mutex.Unlock()
c.IsBackground = isBackground
}

0 comments on commit cff6f9a

Please sign in to comment.