feat: incr sync version.

This commit is contained in:
Gordon
2024-06-24 17:48:33 +08:00
parent e8ccae6349
commit 88b8043224
308 changed files with 55952 additions and 59 deletions

View File

@@ -0,0 +1,27 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=main
BIN_DIR=./
LAN_FILE=.go
GO_FILE:=${BINARY_NAME}${LAN_FILE}
all: gotool build
build:
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv main open_im_test_client
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi

View File

@@ -0,0 +1,245 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"context"
"errors"
"github.com/openimsdk/openim-sdk-core/v3/internal/util"
"github.com/openimsdk/openim-sdk-core/v3/pkg/ccontext"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/openim-sdk-core/v3/sdk_struct"
"net"
"os"
"strconv"
"sync"
"time"
authPB "github.com/openimsdk/protocol/auth"
"github.com/openimsdk/protocol/sdkws"
userPB "github.com/openimsdk/protocol/user"
"github.com/openimsdk/tools/log"
)
func GenUid(uid int, prefix string) string {
if getMyIP() == "" {
log.ZError(ctx, "getMyIP() failed, exit ", errors.New("getMyIP() failed"))
os.Exit(1)
}
UidPrefix := getMyIP() + "_" + prefix + "_"
return UidPrefix + strconv.FormatInt(int64(uid), 10)
}
func RegisterOnlineAccounts(number int) {
var wg sync.WaitGroup
wg.Add(number)
for i := 0; i < number; i++ {
go func(t int) {
userID := GenUid(t, "online")
register(userID)
log.ZInfo(ctx, "register ", userID)
wg.Done()
}(i)
}
wg.Wait()
log.ZInfo(ctx, "RegisterAccounts finish ", number)
}
type GetTokenReq struct {
Secret string `json:"secret"`
Platform int `json:"platform"`
Uid string `json:"uid"`
}
type RegisterReq struct {
Secret string `json:"secret"`
Platform int `json:"platform"`
Uid string `json:"uid"`
Name string `json:"name"`
}
type ResToken struct {
Data struct {
ExpiredTime int64 `json:"expiredTime"`
Token string `json:"token"`
Uid string `json:"uid"`
}
ErrCode int `json:"errCode"`
ErrMsg string `json:"errMsg"`
}
var AdminToken = ""
func init() {
AdminToken = getToken("openIM123456")
if err := log.InitFromConfig("open-im-sdk-core", "", int(LogLevel), IsLogStandardOutput, false, LogFilePath, 0, 24, "23432"); err != nil {
//fmt.Println("123456", "log init failed ", err.Error())
}
}
var ctx context.Context
func register(uid string) error {
ctx = ccontext.WithInfo(context.Background(), &ccontext.GlobalConfig{
UserID: uid,
Token: AdminToken,
IMConfig: sdk_struct.IMConfig{
PlatformID: PlatformID,
ApiAddr: APIADDR,
WsAddr: WSADDR,
LogLevel: LogLevel,
},
})
ctx = ccontext.WithOperationID(ctx, "123456")
//ACCOUNTCHECK
var getAccountCheckReq userPB.AccountCheckReq
var getAccountCheckResp userPB.AccountCheckResp
getAccountCheckReq.CheckUserIDs = []string{uid}
for {
err := util.ApiPost(ctx, "/user/account_check", &getAccountCheckReq, &getAccountCheckResp)
if err != nil {
return err
}
if len(getAccountCheckResp.Results) == 1 &&
getAccountCheckResp.Results[0].AccountStatus == "registered" {
log.ZWarn(ctx, "account already registered", errors.New("Already registered "), "userIDs", getAccountCheckReq.CheckUserIDs[0],
"uid", uid, "getAccountCheckResp", getAccountCheckResp)
userLock.Lock()
allUserID = append(allUserID, uid)
userLock.Unlock()
return nil
} else if len(getAccountCheckResp.Results) == 1 &&
getAccountCheckResp.Results[0].AccountStatus == "unregistered" {
log.ZInfo(ctx, "account not register", "userIDs", getAccountCheckReq.CheckUserIDs[0], "uid", uid, "getAccountCheckResp",
getAccountCheckResp)
break
} else {
log.ZError(ctx, " failed, continue ", err, "userIDs", getAccountCheckReq.CheckUserIDs[0], "register address",
REGISTERADDR, "getAccountCheckReq", getAccountCheckReq)
continue
}
}
var rreq userPB.UserRegisterReq
rreq.Users = []*sdkws.UserInfo{{UserID: uid}}
for {
err := util.ApiPost(ctx, "/auth/user_register", &rreq, nil)
if err != nil {
log.ZError(ctx, "post failed ,continue ", errors.New("post failed ,continue"), "register address", REGISTERADDR,
"getAccountCheckReq", getAccountCheckReq)
time.Sleep(100 * time.Millisecond)
continue
} else {
log.ZInfo(ctx, "register ok ", "register address", REGISTERADDR, "getAccountCheckReq", getAccountCheckReq)
userLock.Lock()
allUserID = append(allUserID, uid)
userLock.Unlock()
return nil
}
}
}
func getToken(uid string) string {
ctx = ccontext.WithInfo(context.Background(), &ccontext.GlobalConfig{
UserID: uid,
Token: "",
IMConfig: sdk_struct.IMConfig{
PlatformID: PlatformID,
ApiAddr: APIADDR,
WsAddr: WSADDR,
LogLevel: LogLevel,
},
})
ctx = ccontext.WithOperationID(ctx, utils.OperationIDGenerator())
url := TOKENADDR
req := authPB.UserTokenReq{
Secret: SECRET,
PlatformID: PlatformID,
UserID: uid,
}
resp := authPB.UserTokenResp{}
err := util.ApiPost(ctx, "/auth/user_token", &req, &resp)
if err != nil {
log.ZError(ctx, "Post2Api failed ", errors.New("Post2Api failed "), "userID", req.UserID, "url", url, "req", req)
return ""
}
log.ZInfo(ctx, "get token: ", "userID", req.UserID, "token", resp.Token)
return resp.Token
}
func RunGetToken(strMyUid string) string {
var token string
for true {
token = getToken(strMyUid)
if token == "" {
time.Sleep(time.Duration(100) * time.Millisecond)
continue
} else {
break
}
}
return token
}
func getMyIP() string {
addrs, err := net.InterfaceAddrs()
if err != nil {
log.ZError(ctx, "InterfaceAddrs failed ", errors.New("InterfaceAddrs failed "), "addrs", addrs)
os.Exit(1)
return ""
}
for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
return ipnet.IP.String()
}
}
}
return ""
}
func RegisterReliabilityUser(id int, timeStamp string) {
userID := GenUid(id, "reliability_"+timeStamp)
register(userID)
token := RunGetToken(userID)
coreMgrLock.Lock()
defer coreMgrLock.Unlock()
allLoginMgr[id] = &CoreNode{token: token, userID: userID}
}
func WorkGroupRegisterReliabilityUser(id int) {
userID := GenUid(id, "workgroup")
// register(userID)
token := RunGetToken(userID)
coreMgrLock.Lock()
defer coreMgrLock.Unlock()
log.ZInfo(ctx, "WorkGroupRegisterReliabilityUser : ", "userID", userID, "token: ", token)
allLoginMgr[id] = &CoreNode{token: token, userID: userID}
}
func RegisterPressUser(id int) {
userID := GenUid(id, "press")
register(userID)
token := RunGetToken(userID)
coreMgrLock.Lock()
defer coreMgrLock.Unlock()
allLoginMgr[id] = &CoreNode{token: token, userID: userID}
}

View File

@@ -0,0 +1,75 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"github.com/openimsdk/openim-sdk-core/v3/pkg/constant"
"sync"
)
var LogLevel uint32 = 5
var PlatformID = int32(3)
var LogName = ""
var IsLogStandardOutput = true
var LogFilePath = ""
var ReliabilityUserA = 1234567
var ReliabilityUserB = 1234567
var (
//TESTIP = "121.5.182.23"
TESTIP = "59.36.173.89"
//TESTIP = "121.37.25.71"
//TESTIP = "open-im-test.rentsoft.cn"
APIADDR = "http://" + TESTIP + ":10002"
WSADDR = "ws://" + TESTIP + ":10001"
REGISTERADDR = APIADDR + "/auth/user_register"
TOKENADDR = APIADDR + "/auth/user_token"
SECRET = "openIM123"
SENDINTERVAL = 20
GETSELFUSERINFO = APIADDR + "/user/get_self_user_info"
CREATEGROUP = APIADDR + constant.CreateGroupRouter
ACCOUNTCHECK = APIADDR + "/user/account_check"
GETGROUPSINFOROUTER = APIADDR + constant.GetGroupsInfoRouter
)
var coreMgrLock sync.RWMutex
var allLoginMgr map[int]*CoreNode
var allLoginMgrtmp []*CoreNode
var userLock sync.RWMutex
var allUserID []string
var allToken []string
// var allWs []*interaction.Ws
var sendSuccessCount, sendFailedCount int
var sendSuccessLock sync.RWMutex
var sendFailedLock sync.RWMutex
var msgNumInOneClient = 0
// var Msgwg sync.WaitGroup
var sendMsgClient = 0
var MaxNumGoroutine = 100000
// 常量
var (
RELIABILITY = "reliability_"
)

View File

@@ -0,0 +1,115 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"encoding/json"
"errors"
"fmt"
"github.com/openimsdk/openim-sdk-core/v3/open_im_sdk"
"github.com/openimsdk/openim-sdk-core/v3/pkg/constant"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/openim-sdk-core/v3/sdk_struct"
"github.com/openimsdk/tools/log"
"time"
)
type BaseSuccessFailed struct {
successData string
errCode int
errMsg string
funcName string
time time.Time
}
func (b *BaseSuccessFailed) OnError(errCode int32, errMsg string) {
b.errCode = -1
b.errMsg = errMsg
log.ZError(ctx, "login failed", errors.New("login failed"), "errCode", errCode, "errMsg", errMsg)
}
func (b *BaseSuccessFailed) OnSuccess(data string) {
b.errCode = 1
b.successData = data
log.ZInfo(ctx, "login success", "data", data, "time since", time.Since(b.time))
}
func InOutDoTest(uid, tk, ws, api string) {
var cf sdk_struct.IMConfig
cf.ApiAddr = api
cf.PlatformID = constant.WindowsPlatformID
cf.WsAddr = ws
cf.DataDir = "./"
cf.LogLevel = LogLevel
cf.IsExternalExtensions = true
cf.IsLogStandardOutput = true
cf.LogFilePath = "./"
b, _ := json.Marshal(cf)
s := string(b)
fmt.Println(s)
var testinit testInitLister
operationID := utils.OperationIDGenerator()
if !open_im_sdk.InitSDK(&testinit, operationID, s) {
fmt.Println("", "InitSDK failed")
return
}
var testConversation conversationCallBack
open_im_sdk.SetConversationListener(&testConversation)
var testUser userCallback
open_im_sdk.SetUserListener(testUser)
var msgCallBack MsgListenerCallBak
open_im_sdk.SetAdvancedMsgListener(&msgCallBack)
var batchMsg BatchMsg
open_im_sdk.SetBatchMsgListener(&batchMsg)
var friendListener testFriendListener
open_im_sdk.SetFriendListener(friendListener)
var groupListener testGroupListener
open_im_sdk.SetGroupListener(groupListener)
InOutlllogin(uid, tk)
}
func InOutlllogin(uid, tk string) {
var callback BaseSuccessFailed
callback.time = time.Now()
callback.funcName = utils.GetSelfFuncName()
operationID := utils.OperationIDGenerator()
open_im_sdk.Login(&callback, operationID, uid, tk)
for {
if callback.errCode == 1 {
return
} else if callback.errCode == -1 {
time.Sleep(100 * time.Millisecond)
} else {
time.Sleep(100 * time.Millisecond)
}
}
}
func InOutLogout() {
var callback BaseSuccessFailed
callback.funcName = utils.GetSelfFuncName()
opretaionID := utils.OperationIDGenerator()
open_im_sdk.Logout(&callback, opretaionID)
}

View File

@@ -0,0 +1,43 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
//funcation OnlineTest(number int) {
// t1 := time.Now()
// RegisterOnlineAccounts(number)
// log.Info("", "RegisterAccounts cost time: ", time.Since(t1), "Online client number ", number)
// t2 := time.Now()
// var wg sync.WaitGroup
// wg.Add(number)
// for i := 0; i < number; i++ {
// go funcation(t int) {
// GenWsConn(t)
// log.Info("GenWsConn, the: ", t, " user")
// wg.Done()
// }(i)
// }
// wg.Wait()
// log.Info("", "OnlineTest finish cost time: ", time.Since(t2), "Online client number ", number)
//}
//funcation GenWsConn(id int) {
// userID := GenUid(id, "online")
// token := RunGetToken(userID)
// wsRespAsyn := interaction.NewWsRespAsyn()
// wsConn := interaction.NewWsConn(new(testInitLister), token, userID, false)
// cmdWsCh := make(chan common.Cmd2Value, 10)
// pushMsgAndMaxSeqCh := make(chan common.Cmd2Value, 1000)
// interaction.NewWs(wsRespAsyn, wsConn, cmdWsCh, pushMsgAndMaxSeqCh, nil)
//}

View File

@@ -0,0 +1,687 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"errors"
"fmt"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/tools/log"
"io/ioutil"
"math/rand"
"os"
"runtime"
"strconv"
"strings"
"sync"
"time"
)
func GetFileContentAsStringLines(filePath string) ([]string, error) {
result := []string{}
b, err := ioutil.ReadFile(filePath)
if err != nil {
return result, err
}
s := string(b)
for _, lineStr := range strings.Split(s, "\n") {
lineStr = strings.TrimSpace(lineStr)
if lineStr == "" {
continue
}
result = append(result, lineStr)
}
return result, nil
}
func GetCmd(myUid int, filename string) int {
cmd, err := GetFileContentAsStringLines("cmd.txt")
if err != nil {
fmt.Println("GetFileContentAsStringLines failed")
return -1
}
if len(cmd) < myUid {
fmt.Println("len failed")
return -1
}
return int(utils.StringToInt64(cmd[myUid-1]))
}
func ReliabilityTest(msgNumOneClient int, intervalSleepMS int, randSleepMaxSecond int, clientNum int) {
msgNumInOneClient = msgNumOneClient
timeStamp := utils.Int64ToString(time.Now().Unix())
var wg sync.WaitGroup
// 注册
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
RegisterReliabilityUser(idx, timeStamp)
wg.Done()
}(i)
}
wg.Wait()
log.ZWarn(ctx, "RegisterReliabilityUser finished, clientNum:", errors.New(""), "clientNum", clientNum)
log.ZWarn(ctx, "init, login, send msg, start", errors.New(""))
rand.Seed(time.Now().UnixNano())
// 一半用户立刻登录发消息
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
rdSleep := rand.Intn(randSleepMaxSecond) + 1
isSend := 0 // 消息是否成功发送控制量
if isSend == 0 {
go func(idx int) {
log.ZWarn(ctx, " send msg flag true ", errors.New(""), "idx", idx)
ReliabilityOne(idx, rdSleep, true, intervalSleepMS)
wg.Done()
}(i)
sendMsgClient++
} else {
go func(idx int) {
log.ZWarn(ctx, " send msg flag false ", errors.New(""), "idx", idx)
ReliabilityOne(idx, rdSleep, false, intervalSleepMS)
wg.Done()
}(i)
}
}
wg.Wait()
log.ZWarn(ctx, "send msg finish, CheckReliabilityResult", errors.New(""))
for {
// 消息异步落库可能出现延迟,每隔五秒再检查一次
if CheckReliabilityResult(msgNumOneClient, clientNum) {
log.ZWarn(ctx, "CheckReliabilityResult ok, exit", errors.New(""))
os.Exit(0)
return
} else {
log.ZWarn(ctx, "CheckReliabilityResult failed , wait.... ", errors.New(""))
}
time.Sleep(time.Duration(5) * time.Second)
}
}
func WorkGroupReliabilityTest(msgNumOneClient int, intervalSleepMS int, randSleepMaxSecond int, clientNum int, groupID string) {
msgNumInOneClient = msgNumOneClient
//timeStamp := utils.Int64ToString(time.Now().Unix())
var wg sync.WaitGroup
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
WorkGroupRegisterReliabilityUser(idx)
wg.Done()
}(i)
}
wg.Wait()
log.ZWarn(ctx, "RegisterReliabilityUser finished", errors.New(""), "clientNum", clientNum)
log.ZWarn(ctx, " init, login, send msg, start ", errors.New(""))
rand.Seed(time.Now().UnixNano())
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
rdSleep := rand.Intn(randSleepMaxSecond) + 1
isSend := 0
if isSend == 0 {
go func(idx int) {
log.ZWarn(ctx, "send msg flag true", errors.New(""), "idx", idx)
WorkGroupReliabilityOne(idx, rdSleep, true, intervalSleepMS, groupID)
wg.Done()
}(i)
sendMsgClient++
} else {
go func(idx int) {
log.ZWarn(ctx, "send msg flag false", errors.New(""), "idx", idx)
ReliabilityOne(idx, rdSleep, false, intervalSleepMS)
wg.Done()
}(i)
}
}
wg.Wait()
//log.Warn("send msg finish, CheckReliabilityResult")
for {
if CheckReliabilityResult(msgNumOneClient, clientNum) {
//log.Warn("", "CheckReliabilityResult ok, exit")
os.Exit(0)
return
} else {
//log.Warn("", "CheckReliabilityResult failed , wait.... ")
}
time.Sleep(time.Duration(5) * time.Second)
}
}
func WorkGroupMsgDelayTest(msgNumOneClient int, intervalSleepMS int, randSleepMaxSecond int, clientBegin int, clientEnd int, groupID string) {
msgNumInOneClient = msgNumOneClient
var wg sync.WaitGroup
wg.Add(clientEnd - clientBegin + 1)
for i := clientBegin; i <= clientEnd; i++ {
go func(idx int) {
WorkGroupRegisterReliabilityUser(idx)
wg.Done()
}(i)
}
wg.Wait()
//log.Warn("", "RegisterReliabilityUser finished, client: ", clientBegin, clientEnd)
//log.Warn("", " init, login, send msg, start ")
rand.Seed(time.Now().UnixNano())
wg.Add(clientEnd - clientBegin + 1)
for i := clientBegin; i <= clientEnd; i++ {
rdSleep := rand.Intn(randSleepMaxSecond) + 1
isSend := 0
if isSend == 0 {
go func(idx int) {
//log.Warn("", " send msg flag true ", idx)
WorkGroupReliabilityOne(idx, rdSleep, true, intervalSleepMS, groupID)
wg.Done()
}(i)
sendMsgClient++
} else {
go func(idx int) {
//log.Warn("", " send msg flag false ", idx)
WorkGroupReliabilityOne(idx, rdSleep, false, intervalSleepMS, groupID)
wg.Done()
}(i)
}
}
wg.Wait()
//log.Warn("send msg finish, CheckReliabilityResult")
for {
if CheckReliabilityResult(msgNumOneClient, clientEnd-clientBegin+1) {
//log.Warn("", "CheckReliabilityResult ok, exit")
os.Exit(0)
return
} else {
//log.Warn("", "CheckReliabilityResult failed , wait.... ")
}
time.Sleep(time.Duration(5) * time.Second)
}
}
func PressTest(msgNumOneClient int, intervalSleepMS int, clientNum int) {
msgNumInOneClient = msgNumOneClient
//timeStamp := utils.Int64ToString(time.Now().Unix())
var wg sync.WaitGroup
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
RegisterPressUser(idx)
log.ZInfo(ctx, "GetUserTokenFinish", "index", idx)
wg.Done()
}(i)
}
wg.Wait()
//log.Warn("", "get all user token finish ", clientNum, " cost time: ", time.Since(t1))
//log.Warn("", "init and login begin ")
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
strMyUid := allLoginMgr[idx].userID
token := allLoginMgr[idx].token
PressInitAndLogin(idx, strMyUid, token, WSADDR, APIADDR)
wg.Done()
}(i)
}
wg.Wait()
//log.Warn("", "init and login end ", " cost time: ", time.Since(t1))
//log.Warn("", "send msg begin ")
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
PressOne(idx, 0, true, intervalSleepMS)
//log.Warn("", "press finished ", idx)
wg.Done()
}(i)
}
wg.Wait()
sendMsgTotalSuccessNum := uint32(0)
sendMsgTotalFailedNum := uint32(0)
for _, v := range allLoginMgr {
sendMsgTotalSuccessNum += v.sendMsgSuccessNum
sendMsgTotalFailedNum += v.sendMsgFailedNum
}
//log.Warn("send msg end ", "number of messages expected to be sent: ", clientNum*msgNumOneClient, " sendMsgTotalSuccessNum: ", sendMsgTotalSuccessNum, " sendMsgTotalFailedNum: ", sendMsgTotalFailedNum, "cost time: ", time.Since(t1))
}
func WorkGroupPressTest(msgNumOneClient int, intervalSleepMS int, clientNum int, groupID string) {
msgNumInOneClient = msgNumOneClient
var wg sync.WaitGroup
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
WorkGroupRegisterReliabilityUser(idx)
log.ZInfo(ctx, "GetUserTokenFinish", "index", idx)
wg.Done()
}(i)
}
wg.Wait()
//log.Warn("", "get all user token finish ", clientNum, " cost time: ", time.Since(t1))
//log.Warn("", "init and login begin ")
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
strMyUid := allLoginMgr[idx].userID
token := allLoginMgr[idx].token
ReliabilityInitAndLogin(idx, strMyUid, token, WSADDR, APIADDR)
wg.Done()
}(i)
}
wg.Wait()
//log.Warn("", "init and login end ", " cost time: ", time.Since(t1))
//log.Warn("", "send msg begin ")
wg.Add(clientNum)
for i := 0; i < clientNum; i++ {
go func(idx int) {
WorkGroupPressOne(idx, 0, true, intervalSleepMS, groupID)
wg.Done()
}(i)
}
wg.Wait()
sendMsgTotalSuccessNum := uint32(0)
sendMsgTotalFailedNum := uint32(0)
for _, v := range allLoginMgr {
sendMsgTotalSuccessNum += v.sendMsgSuccessNum
sendMsgTotalFailedNum += v.sendMsgFailedNum
}
//log.Warn("send msg end ", "number of messages expected to be sent: ", clientNum*msgNumOneClient, " sendMsgTotalSuccessNum: ", sendMsgTotalSuccessNum, " sendMsgTotalFailedNum: ", sendMsgTotalFailedNum, "cost time: ", time.Since(t1))
}
func CheckReliabilityResult(msgNumOneClient int, clientNum int) bool {
log.ZInfo(ctx, "StartCheckMapSendToMapRecv")
sameNum := 0
// 消息数量不一致说明出现丢失
if len(SendSuccAllMsg)+len(SendFailedAllMsg) != msgNumOneClient*clientNum {
//log.Warn("", utils.GetSelfFuncName(), " send msg success number: ", len(SendSuccAllMsg),
// " send msg failed number: ", len(SendFailedAllMsg), " all: ", msgNumOneClient*clientNum)
return false
}
for ksend, _ := range SendSuccAllMsg {
_, ok := RecvAllMsg[ksend] // RecvAllMsg 的初始化何时?
if ok {
sameNum++
} else {
// 埋点日志,第 ksend 个消息数据 本地和服务器不一致
//log.Error("", "check failed not in recv ", ksend)
//log.Error("", "send failed num: ", len(SendFailedAllMsg),
// " send success num: ", len(SendSuccAllMsg), " recv num: ", len(RecvAllMsg))
return false
}
}
log.ZInfo(ctx, "CheckMapSendToMapRecvOK", "sameNum", sameNum)
//log.Info("", "start check map recv -> map send ")
//sameNum = 0
//for k1, _ := range RecvAllMsg {
// _, ok := SendSuccAllMsg[k1]
// if ok {
// sameNum++
// //x := v1 + v2
// //x = x + x
//
// } else {
// log.Error("", "check failed not in send ", k1, len(SendFailedAllMsg), len(SendSuccAllMsg), len(RecvAllMsg))
// // return false
// }
//}
minCostTime := int64(1000000)
maxCostTime := int64(0)
totalCostTime := int64(0)
for ksend, vsend := range SendSuccAllMsg {
krecv, ok := RecvAllMsg[ksend]
if ok {
sameNum++
costTime := krecv.RecvTime - vsend.SendTime
totalCostTime += costTime
if costTime > maxCostTime {
maxCostTime = costTime
}
if minCostTime > costTime {
minCostTime = costTime
}
}
}
//log.Warn("", "need send msg num : ", sendMsgClient*msgNumInOneClient)
//log.Warn("", "send msg succ num ", len(SendSuccAllMsg))
//log.Warn("", "send msg failed num ", len(SendFailedAllMsg))
//log.Warn("", "recv msg succ num ", len(RecvAllMsg))
//log.Warn("", "minCostTime: ", minCostTime, "ms, maxCostTime: ", maxCostTime, "ms, average cost time: ",
// totalCostTime/(int64(sendMsgClient*msgNumInOneClient)), "ms", " maxCostMsgID: ", maxCostMsgID)
return true
}
func ReliabilityOne(index int, beforeLoginSleep int, isSendMsg bool, intervalSleepMS int) {
// time.Sleep(time.Duration(beforeLoginSleep) * time.Second)
strMyUid := allLoginMgr[index].userID
token := allLoginMgr[index].token
log.ZInfo(ctx, "LoginOKClientNum", "clientNum", len(allLoginMgr), "userID", strMyUid, "token", token, "index", index)
ReliabilityInitAndLogin(index, strMyUid, token, WSADDR, APIADDR)
//log.Warn("start One", index, beforeLoginSleep, isSendMsg, strMyUid, token, WSADDR, APIADDR)
msgnum := msgNumInOneClient
uidNum := len(allLoginMgr)
rand.Seed(time.Now().UnixNano())
if msgnum == 0 {
os.Exit(0)
}
if !isSendMsg {
// Msgwg.Done()
} else {
for i := 0; i < msgnum; i++ {
var r int
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
for {
r = rand.Intn(uidNum)
if r == index {
continue
} else {
break
}
}
recvId := allLoginMgr[r].userID
idx := strconv.FormatInt(int64(i), 10)
for {
if runtime.NumGoroutine() > MaxNumGoroutine {
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
//log.Warn("", "NumGoroutine > max ", runtime.NumGoroutine(), MaxNumGoroutine)
continue
} else {
break
}
}
DoTestSendMsg(index, strMyUid, recvId, "", idx)
}
//Msgwg.Done()
}
}
func WorkGroupReliabilityOne(index int, beforeLoginSleep int, isSendMsg bool, intervalSleepMS int, groupID string) {
// time.Sleep(time.Duration(beforeLoginSleep) * time.Second)
strMyUid := allLoginMgr[index].userID
token := allLoginMgr[index].token
ReliabilityInitAndLogin(index, strMyUid, token, WSADDR, APIADDR)
log.ZInfo(ctx, "LoginSuccess", "clientNum", len(allLoginMgr))
//log.Warn("start One", index, beforeLoginSleep, isSendMsg, strMyUid, token, WSADDR, APIADDR)
msgnum := msgNumInOneClient
uidNum := len(allLoginMgr)
var idx string
rand.Seed(time.Now().UnixNano())
if msgnum == 0 {
os.Exit(0)
}
if !isSendMsg {
// Msgwg.Done()
} else {
for i := 0; i < msgnum; i++ {
var r int
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
for {
r = rand.Intn(uidNum)
if r == index {
continue
} else {
break
}
}
idx = strconv.FormatInt(int64(i), 10)
for {
if runtime.NumGoroutine() > MaxNumGoroutine {
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
//log.Warn("", "NumGoroutine > max ", runtime.NumGoroutine(), MaxNumGoroutine)
continue
} else {
break
}
}
DoTestSendMsg(index, strMyUid, "", groupID, idx)
}
//Msgwg.Done()
}
}
func WorkGroupMsgDelayOne(index int, beforeLoginSleep int, isSendMsg bool, intervalSleepMS int, groupID string) {
// time.Sleep(time.Duration(beforeLoginSleep) * time.Second)
strMyUid := allLoginMgr[index].userID
token := allLoginMgr[index].token
ReliabilityInitAndLogin(index, strMyUid, token, WSADDR, APIADDR)
log.ZInfo(ctx, "LoginSuccess", "clientNum", len(allLoginMgr))
//log.Warn("start One", index, beforeLoginSleep, isSendMsg, strMyUid, token, WSADDR, APIADDR)
msgnum := msgNumInOneClient
uidNum := len(allLoginMgr)
var idx string
rand.Seed(time.Now().UnixNano())
if msgnum == 0 {
os.Exit(0)
}
if !isSendMsg {
// Msgwg.Done()
} else {
for i := 0; i < msgnum; i++ {
var r int
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
for {
r = rand.Intn(uidNum)
if r == index {
continue
} else {
break
}
}
idx = strconv.FormatInt(int64(i), 10)
for {
if runtime.NumGoroutine() > MaxNumGoroutine {
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
//log.Warn("", "NumGoroutine > max ", runtime.NumGoroutine(), MaxNumGoroutine)
continue
} else {
break
}
}
DoTestSendMsg(index, strMyUid, "", groupID, idx)
}
//Msgwg.Done()
}
}
//
//funcation WorkGroupMsgDelayOne(sendID1 string, beforeLoginSleep int, isSendMsg bool, intervalSleepMS int, groupID string) {
// // time.Sleep(time.Duration(beforeLoginSleep) * time.Second)
// strMyUid := allLoginMgr[index].userID
// token := allLoginMgr[index].token
// ReliabilityInitAndLogin(index, strMyUid, token, WSADDR, APIADDR)
// log.Info("", "login ok client num: ", len(allLoginMgr))
// log.Warn("start One", index, beforeLoginSleep, isSendMsg, strMyUid, token, WSADDR, APIADDR)
// msgnum := msgNumInOneClient
// uidNum := len(allLoginMgr)
// var idx string
// rand.Seed(time.Now().UnixNano())
// if msgnum == 0 {
// os.Exit(0)
// }
// if !isSendMsg {
// // Msgwg.Done()
// } else {
// for i := 0; i < msgnum; i++ {
// var r int
// time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
// for {
// r = rand.Intn(uidNum)
// if r == index {
// continue
// } else {
//
// break
// }
//
// }
//
// idx = strconv.FormatInt(int64(i), 10)
// for {
// if runtime.NumGoroutine() > MaxNumGoroutine {
// time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
// log.Warn("", "NumGoroutine > max ", runtime.NumGoroutine(), MaxNumGoroutine)
// continue
// } else {
// break
// }
// }
//
// DoTestSendMsg(index, strMyUid, "", groupID, idx)
//
// }
// //Msgwg.Done()
// }
//}
func PressOne(index int, beforeLoginSleep int, isSendMsg bool, intervalSleepMS int) {
if beforeLoginSleep != 0 {
time.Sleep(time.Duration(beforeLoginSleep) * time.Millisecond)
}
strMyUid := allLoginMgr[index].userID
token := allLoginMgr[index].token
// ReliabilityInitAndLogin(index, strMyUid, token, WSADDR, APIADDR)
log.ZInfo(ctx, "LoginSuccess", "clientNum", len(allLoginMgr))
log.ZInfo(ctx, "StartOne", "index", index, "beforeLoginSleep", beforeLoginSleep, "isSendMsg", isSendMsg, "senderUID", strMyUid, "token", token, "wsAddr", WSADDR, "apiAddr", APIADDR)
msgnum := msgNumInOneClient
uidNum := len(allLoginMgr)
var recvId string
var idx string
rand.Seed(time.Now().UnixNano())
if msgnum == 0 {
os.Exit(0)
}
if !isSendMsg {
// Msgwg.Done()
} else {
for i := 0; i < msgnum; i++ {
var r int
// time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
for {
r = rand.Intn(uidNum)
if r == index {
continue
} else {
break
}
}
recvId = allLoginMgr[r].userID
idx = strconv.FormatInt(int64(i), 10)
for {
if runtime.NumGoroutine() > MaxNumGoroutine {
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
//log.Warn("", " NumGoroutine > max ", runtime.NumGoroutine(), MaxNumGoroutine)
continue
} else {
break
}
}
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
//DoTestSendMsg(index, strMyUid, recvId, idx)
if sendPressMsg(index, strMyUid, recvId, "", idx) {
allLoginMgr[index].sendMsgSuccessNum++
} else {
allLoginMgr[index].sendMsgFailedNum++
}
}
//Msgwg.Done()
}
}
func WorkGroupPressOne(index int, beforeLoginSleep int, isSendMsg bool, intervalSleepMS int, groupID string) {
if beforeLoginSleep != 0 {
time.Sleep(time.Duration(beforeLoginSleep) * time.Millisecond)
}
strMyUid := allLoginMgr[index].userID
token := allLoginMgr[index].token
//ReliabilityInitAndLogin(index, strMyUid, token, WSADDR, APIADDR)
log.ZInfo(ctx, "LoginSuccess", "clientNum", len(allLoginMgr))
log.ZInfo(ctx, "StartOne", "index", index, "beforeLoginSleep", beforeLoginSleep, "isSendMsg", isSendMsg, "senderUID", strMyUid, "token", token, "wsAddr", WSADDR, "apiAddr", APIADDR)
msgnum := msgNumInOneClient
var idx string
rand.Seed(time.Now().UnixNano())
if msgnum == 0 {
os.Exit(0)
}
if !isSendMsg {
} else {
for i := 0; i < msgnum; i++ {
idx = strconv.FormatInt(int64(i), 10)
for {
if runtime.NumGoroutine() > MaxNumGoroutine {
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
//log.Warn("", " NumGoroutine > max ", runtime.NumGoroutine(), MaxNumGoroutine)
continue
} else {
break
}
}
log.ZInfo(ctx, "SendPressMsgBegin", "index", index, "senderUID", strMyUid, "groupID", groupID)
if sendPressMsg(index, strMyUid, "", groupID, idx) {
allLoginMgr[index].sendMsgSuccessNum++
} else {
allLoginMgr[index].sendMsgFailedNum++
}
log.ZInfo(ctx, "sendPressMsg end")
time.Sleep(time.Duration(intervalSleepMS) * time.Millisecond)
}
}
}

View File

@@ -0,0 +1,138 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"github.com/openimsdk/openim-sdk-core/v3/open_im_sdk"
"github.com/openimsdk/openim-sdk-core/v3/pkg/constant"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/protocol/sdkws"
"github.com/openimsdk/tools/log"
)
func init() {
//sdk_struct.SvrConf = sdk_struct.IMConfig{Platform: 1, ApiAddr: APIADDR, WsAddr: WSADDR, DataDir: "./", LogLevel: 6, ObjectStorage: "cos"}
allLoginMgr = make(map[int]*CoreNode)
}
//funcation InitMgr(num int) {
// log.Warn("", "allLoginMgr cap: ", num)
// allLoginMgr = make(map[int]*CoreNode, num)
//}
type CoreNode struct {
token string
userID string
mgr *open_im_sdk.LoginMgr
sendMsgSuccessNum uint32
sendMsgFailedNum uint32
idx int
}
func addSendSuccess() {
sendSuccessLock.Lock()
defer sendSuccessLock.Unlock()
sendSuccessCount++
}
func addSendFailed() {
sendFailedLock.Lock()
defer sendFailedLock.Unlock()
sendFailedCount++
}
//
//funcation TestSendCostTime() {
// GenWsConn(0)
// sendID := allUserID[0]
// recvID := allUserID[0]
// for {
// operationID := utils.OperationIDGenerator()
// b := SendTextMessage("test", sendID, recvID, operationID, allWs[0])
// if b {
// log.Debug(operationID, sendID, recvID, "SendTextMessage success")
// } else {
// log.Error(operationID, sendID, recvID, "SendTextMessage failed")
// }
// time.Sleep(time.Duration(5) * time.Second)
// log.Debug(operationID, "//////////////////////////////////")
// }
//
//}
//funcation TestSend(idx int, text string, uidNum, intervalSleep int) {
// for {
// operationID := utils.OperationIDGenerator()
// sendID := allUserID[idx]
// recvID := allUserID[rand.Intn(uidNum)]
// b := SendTextMessage(text, sendID, recvID, operationID, allWs[idx])
// if b {
// log.Debug(operationID, sendID, recvID, "SendTextMessage success")
// } else {
// log.Error(operationID, sendID, recvID, "SendTextMessage failed")
// }
// time.Sleep(time.Duration(rand.Intn(intervalSleep)) * time.Millisecond)
// }
//}
//
//funcation sendPressMsg(idx int, text string, uidNum, intervalSleep int) {
// for {
// operationID := utils.OperationIDGenerator()
// sendID := allUserID[idx]
// recvID := allUserID[rand.Intn(uidNum)]
// b := SendTextMessageOnlyForPress(text, sendID, recvID, operationID, allLoginMgr[idx].mgr.Ws())
// if b {
// log.Debug(operationID, sendID, recvID, "SendTextMessage success")
// } else {
// log.Error(operationID, sendID, recvID, "SendTextMessage failed ")
// }
// time.Sleep(time.Duration(rand.Intn(intervalSleep)) * time.Second)
// }
//}
func sendPressMsg(index int, sendId, recvID string, groupID string, idx string) bool {
return SendTextMessageOnlyForPress(idx, sendId, recvID, groupID, utils.OperationIDGenerator())
}
func SendTextMessageOnlyForPress(text, senderID, recvID, groupID, operationID string) bool {
var wsMsgData sdkws.MsgData
options := make(map[string]bool, 2)
wsMsgData.SendID = senderID
if groupID == "" {
wsMsgData.RecvID = recvID
wsMsgData.SessionType = constant.SingleChatType
} else {
wsMsgData.GroupID = groupID
wsMsgData.SessionType = constant.SuperGroupChatType
}
wsMsgData.ClientMsgID = utils.GetMsgID(senderID)
wsMsgData.SenderPlatformID = 1
wsMsgData.MsgFrom = constant.UserMsgType
wsMsgData.ContentType = constant.Text
wsMsgData.Content = []byte(text)
wsMsgData.CreateTime = utils.GetCurrentTimestampByMill()
wsMsgData.Options = options
wsMsgData.OfflinePushInfo = nil
//timeout := 300
log.ZInfo(ctx, "SendReqTest begin ", "operationID", operationID, "wsMsgData", wsMsgData)
//flag := ws.SendReqTest(&wsMsgData, constant.WSSendMsg, timeout, senderID, operationID)
//
//if flag != true {
// log.Warn(operationID, "SendReqTest failed ", wsMsgData)
//}
return true
}

View File

@@ -0,0 +1,927 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"encoding/json"
"fmt"
"sync"
"github.com/openimsdk/openim-sdk-core/v3/open_im_sdk"
"github.com/openimsdk/openim-sdk-core/v3/pkg/constant"
"github.com/openimsdk/openim-sdk-core/v3/pkg/sdk_params_callback"
"github.com/openimsdk/openim-sdk-core/v3/pkg/server_api_params"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/openim-sdk-core/v3/sdk_struct"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/protocol/sdkws"
"github.com/openimsdk/tools/mcontext"
)
//funcation DotestSetConversationRecvMessageOpt() {
// var callback BaseSuccessFailedTest
// callback.funcName = utils.GetSelfFuncName()
// var idList []string
// idList = append(idList, "18567155635")
// jsontest, _ := json.Marshal(idList)
// open_im_sdk.SetConversationRecvMessageOpt(&callback, string(jsontest), 2)
// fmt.Println("SetConversationRecvMessageOpt", string(jsontest))
//}
//
//funcation DoTestGetMultipleConversation() {
// var callback BaseSuccessFailedTest
// callback.funcName = utils.GetSelfFuncName()
// var idList []string
// fmt.Println("DoTestGetMultipleConversation come here")
// idList = append(idList, "single_13977954313", "group_77215e1b13b75f3ab00cb6570e3d9618")
// jsontest, _ := json.Marshal(idList)
// open_im_sdk.GetMultipleConversation(string(jsontest), &callback)
// fmt.Println("GetMultipleConversation", string(jsontest))
//}
//
//funcation DoTestGetConversationRecvMessageOpt() {
// var callback BaseSuccessFailedTest
// callback.funcName = utils.GetSelfFuncName()
// var idList []string
// idList = append(idList, "18567155635")
// jsontest, _ := json.Marshal(idList)
// open_im_sdk.GetConversationRecvMessageOpt(&callback, string(jsontest))
// fmt.Println("GetConversationRecvMessageOpt", string(jsontest))
//}
func DoTestDeleteAllMsgFromLocalAndSvr() {
var deleteConversationCallback DeleteConversationCallBack
operationID := utils.OperationIDGenerator()
log.ZInfo(ctx, operationID, utils.GetSelfFuncName(), "args")
open_im_sdk.DeleteAllMsgFromLocalAndSvr(deleteConversationCallback, operationID)
}
func DoTestSearchLocalMessages() {
//[SearchLocalMessages args: {"conversationID":"single_707010937","keywordList":["1"],"keywordListMatchType":0,"senderUserIDList":[],"messageTypeList":[],"searchTimePosition":0,"searchTimePeriod":0,"pageIndex":1,"count":200}]
var testSearchLocalMessagesCallBack SearchLocalMessagesCallBack
testSearchLocalMessagesCallBack.OperationID = utils.OperationIDGenerator()
var params sdk_params_callback.SearchLocalMessagesParams
params.KeywordList = []string{"1"}
params.ConversationID = "super_group_3907826375"
params.Count = 20
params.PageIndex = 1
//s:=strings.Trim(params.KeywordList[0],"")
//fmt.Println(len(s),s)
//params.KeywordListMatchType = 1
params.MessageTypeList = []int{101, 106}
open_im_sdk.SearchLocalMessages(testSearchLocalMessagesCallBack, testSearchLocalMessagesCallBack.OperationID, utils.StructToJsonString(params))
}
// funcation DoTestGetHistoryMessage(userID string) {
// var testGetHistoryCallBack GetHistoryCallBack
// testGetHistoryCallBack.OperationID = utils.OperationIDGenerator()
// var params sdk_params_callback.GetHistoryMessageListParams
// params.UserID = userID
// params.ConversationID = "super_group_3907826375"
// //params.StartClientMsgID = "97f12899778823019f13ea46b0c1e6dd"
// params.Count = 10
// open_im_sdk.GetHistoryMessageList(testGetHistoryCallBack, testGetHistoryCallBack.OperationID, utils.StructToJsonString(params))
// }
func DoTestFindMessageList() {
var testFindMessageListCallBack FindMessageListCallBack
testFindMessageListCallBack.OperationID = utils.OperationIDGenerator()
var params sdk_params_callback.FindMessageListParams
temp := sdk_params_callback.ConversationArgs{ConversationID: "super_group_4205679980", ClientMsgIDList: []string{"eee68d85a43991d6b2e7354c52c5321d", "736f40f902046a6e879dc7257d3e81df"}}
//temp1 := sdk_params_callback.ConversationArgs{ConversationID: "super_group_3320742908", ClientMsgIDList: []string{"acf09fcdda48bf2cb39faba31ac63b5c", "b121d3a7f269636afd255b6001d3fc80", "d8951d1c5192ad39f37f44de93a83302"}}
params = append(params, &temp)
//params = append(params, &temp1)
open_im_sdk.FindMessageList(testFindMessageListCallBack, testFindMessageListCallBack.OperationID, utils.StructToJsonString(params))
}
func DoTestSetMessageReactionExtensions() {
var testSetMessageReactionExtensionsCallBack SetMessageReactionExtensionsCallBack
testSetMessageReactionExtensionsCallBack.OperationID = utils.OperationIDGenerator()
var params sdk_params_callback.SetMessageReactionExtensionsParams
var data server_api_params.KeyValue
data.TypeKey = "x"
m := make(map[string]interface{})
m["operation"] = "1"
m["operator"] = "1583984945064968192"
data.Value = utils.StructToJsonString(m)
params = append(params, &data)
s := sdk_struct.MsgStruct{}
s.SessionType = 3
s.GroupID = "1420026997"
s.ClientMsgID = "831c270ae1d7472dc633e7be06b37db5"
//params = append(params, &temp1)
// open_im_sdk.SetMessageReactionExtensions(testSetMessageReactionExtensionsCallBack, testSetMessageReactionExtensionsCallBack.OperationID, utils.StructToJsonString(s),
// utils.StructToJsonString(params))
}
func DoTestAddMessageReactionExtensions(index int, operationID string) {
var testAddMessageReactionExtensionsCallBack AddMessageReactionExtensionsCallBack
testAddMessageReactionExtensionsCallBack.OperationID = operationID
fmt.Printf("DoTestAddMessageReactionExtensions opid:", testAddMessageReactionExtensionsCallBack.OperationID, index)
var params sdk_params_callback.AddMessageReactionExtensionsParams
var data server_api_params.KeyValue
data.TypeKey = "x"
m := make(map[string]interface{})
m["operation"] = index
m["operator"] = "1583984945064968192"
data.Value = utils.StructToJsonString(m)
params = append(params, &data)
s := sdk_struct.MsgStruct{}
s.SessionType = 3
s.GroupID = "1623878302774460418"
s.ClientMsgID = "7ca152a836a0f784c07a3b74d4e2a97d"
//params = append(params, &temp1)
// open_im_sdk.AddMessageReactionExtensions(testAddMessageReactionExtensionsCallBack, testAddMessageReactionExtensionsCallBack.OperationID, utils.StructToJsonString(s),
// utils.StructToJsonString(params))
}
func DoTestGetMessageListReactionExtensions(operationID string) {
var testGetMessageReactionExtensionsCallBack GetMessageListReactionExtensionsCallBack
testGetMessageReactionExtensionsCallBack.OperationID = operationID
fmt.Printf("DoTestGetMessageListReactionExtensions opid:", testGetMessageReactionExtensionsCallBack.OperationID)
var ss []sdk_struct.MsgStruct
s := sdk_struct.MsgStruct{}
s.SessionType = 3
s.GroupID = "1623878302774460418"
s.ClientMsgID = "d91943a8085556853b3457e33d1e21b2"
s1 := sdk_struct.MsgStruct{}
s1.SessionType = 3
s1.GroupID = "1623878302774460418"
s1.ClientMsgID = "7ca152a836a0f784c07a3b74d4e2a97d"
ss = append(ss, s)
ss = append(ss, s1)
//params = append(params, &temp1)
// open_im_sdk.GetMessageListReactionExtensions(testGetMessageReactionExtensionsCallBack, testGetMessageReactionExtensionsCallBack.OperationID, utils.StructToJsonString(ss))
}
func DoTestSetAppBadge() {
var testSetAppBadgeCallBack SetAppBadgeCallBack
testSetAppBadgeCallBack.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetAppBadge(testSetAppBadgeCallBack, testSetAppBadgeCallBack.OperationID, 100)
}
func DoTestGetAdvancedHistoryMessageList() {
var testGetHistoryCallBack GetHistoryCallBack
testGetHistoryCallBack.OperationID = utils.OperationIDGenerator()
var params sdk_params_callback.GetAdvancedHistoryMessageListParams
params.ConversationID = "si_7788_7789"
//params.StartClientMsgID = "83ca933d559d0374258550dd656a661c"
params.Count = 20
//params.LastMinSeq = seq
open_im_sdk.GetAdvancedHistoryMessageList(testGetHistoryCallBack, testGetHistoryCallBack.OperationID, utils.StructToJsonString(params))
}
//funcation DoTestGetHistoryMessageReverse(userID string) {
// var testGetHistoryReverseCallBack GetHistoryReverseCallBack
// testGetHistoryReverseCallBack.OperationID = utils.OperationIDGenerator()
// var params sdk_params_callback.GetHistoryMessageListParams
// params.UserID = userID
// params.Count = 10
// params.ConversationID = "single_707008149"
// params.StartClientMsgID = "d40dde77f29b14d3a16ca6f422776890"
// open_im_sdk.GetHistoryMessageListReverse(testGetHistoryReverseCallBack, testGetHistoryReverseCallBack.OperationID, utils.StructToJsonString(params))
//}
//funcation DoTestGetGroupHistoryMessage() {
// var testGetHistoryCallBack GetHistoryCallBack
// testGetHistoryCallBack.OperationID = utils.OperationIDGenerator()
// var params sdk_params_callback.GetHistoryMessageListParams
// params.GroupID = "cb7aaa8e5f83d92db2ed1573cd01870c"
// params.Count = 10
// open_im_sdk.GetHistoryMessageList(testGetHistoryCallBack, testGetHistoryCallBack.OperationID, utils.StructToJsonString(params))
//}
//funcation DoTestGetGroupHistoryMessage() {
// var testGetHistoryCallBack GetHistoryCallBack
// testGetHistoryCallBack.OperationID = utils.OperationIDGenerator()
// var params sdk_params_callback.GetHistoryMessageListParams
// params.GroupID = "cb7aaa8e5f83d92db2ed1573cd01870c"
// params.Count = 10
// open_im_sdk.GetHistoryMessageList(testGetHistoryCallBack, testGetHistoryCallBack.OperationID, utils.StructToJsonString(params))
//}
//funcation DoTestDeleteConversation(conversationID string) {
// var testDeleteConversation DeleteConversationCallBack
// open_im_sdk.DeleteConversation(conversationID, testDeleteConversation)
//
//}
type DeleteConversationCallBack struct {
}
func (d DeleteConversationCallBack) OnError(errCode int32, errMsg string) {
fmt.Printf("DeleteConversationCallBack , errCode:%v,errMsg:%v\n", errCode, errMsg)
}
func (d DeleteConversationCallBack) OnSuccess(data string) {
fmt.Printf("DeleteConversationCallBack , success,data:%v\n", data)
}
type DeleteMessageCallBack struct {
Msg string
}
func (d DeleteMessageCallBack) OnError(errCode int32, errMsg string) {
fmt.Printf("DeleteMessageCallBack , errCode:%v,errMsg:%v\n", errCode, errMsg)
}
func (d *DeleteMessageCallBack) OnSuccess(data string) {
fmt.Printf("DeleteMessageCallBack , success,data:%v\n", data)
d.Msg = data
}
func (d DeleteMessageCallBack) GetMessage() string {
return d.Msg
}
func DoTestDeleteConversationMsgFromLocalAndSvr(conversationID string) {
cb := &DeleteMessageCallBack{}
operationID := utils.OperationIDGenerator()
open_im_sdk.DeleteConversationAndDeleteAllMsg(cb, operationID, conversationID)
}
type TestGetAllConversationListCallBack struct {
OperationID string
}
func (t TestGetAllConversationListCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "TestGetAllConversationListCallBack ", "operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (t TestGetAllConversationListCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "ConversationCallBack ", "operationID", t.OperationID, "data", data)
}
func DoTestGetAllConversation() {
var test TestGetAllConversationListCallBack
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetAllConversationList(test, test.OperationID)
}
func DoTestGetOneConversation(friendID string) {
var test TestGetAllConversationListCallBack
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetOneConversation(test, test.OperationID, constant.SingleChatType, friendID)
}
func DoTestGetConversations(conversationIDs string) {
var test TestGetAllConversationListCallBack
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetMultipleConversation(test, test.OperationID, conversationIDs)
}
type TestSetConversationPinnedCallback struct {
OperationID string
}
func (t TestSetConversationPinnedCallback) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "TestSetConversationPinnedCallback ", "operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (t TestSetConversationPinnedCallback) OnSuccess(data string) {
log.ZInfo(ctx, "TestSetConversationPinnedCallback ", "operationID", t.OperationID, "data", data)
}
func DoTestSetConversationRecvMessageOpt(conversationIDs []string, opt int) {
var callback testProcessGroupApplication
callback.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DoTestSetConversationRecvMessageOpt", "operationID", callback.OperationID, "funcName", utils.GetSelfFuncName(),
"conversationIDs: ", conversationIDs, "opt", opt)
s := utils.StructToJsonString(conversationIDs)
open_im_sdk.SetConversationRecvMessageOpt(callback, callback.OperationID, s, opt)
}
//func DoTestRevoke() {
// var callback testProcessGroupApplication
// open_im_sdk.RevokeMessage(callback, "si_3232515230_8650796072", utils.StructToJsonString(&sdk_struct.MsgStruct{SessionType: 1, ContentType: 101,
// ClientMsgID: "ebfe4e0aa11e7602de3dfe0670b484cd", Seq: 12, SendID: "8650796072", RecvID: "3232515230"}))
//}
func DoTestClearOneConversation() {
var callback testProcessGroupApplication
open_im_sdk.ClearConversationAndDeleteAllMsg(callback, "df", "si_2456093263_9169012630")
}
func DoTestSetConversationPinned(conversationID string, pin bool) {
var test TestSetConversationPinnedCallback
test.OperationID = "testping"
open_im_sdk.PinConversation(test, test.OperationID, conversationID, pin)
}
func DoTestSetOneConversationRecvMessageOpt(conversationID string, opt int) {
var test TestSetConversationPinnedCallback
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetConversationRecvMessageOpt(test, test.OperationID, conversationID, opt)
}
func DoTestSetOneConversationPrivateChat(conversationID string, privateChat bool) {
var test TestSetConversationPinnedCallback
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetConversationPrivateChat(test, test.OperationID, conversationID, privateChat)
}
func DoTestSetBurnDuration(conversationID string) {
var test TestSetConversationPinnedCallback
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetConversationBurnDuration(test, test.OperationID, conversationID, 300)
}
func DoTestSetMsgDestructTime(conversationID string) {
var test TestSetConversationPinnedCallback
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.SetConversationIsMsgDestruct(test, test.OperationID, conversationID, true)
open_im_sdk.SetConversationMsgDestructTime(test, test.OperationID, conversationID, 300010)
}
type TestGetConversationListSplitCallBack struct {
OperationID string
}
func (t TestGetConversationListSplitCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "TestGetConversationListSplitCallBack err ", "operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (t TestGetConversationListSplitCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "TestGetConversationListSplitCallBack success", "operationID", t.OperationID, "data", data)
}
func DoTestGetConversationListSplit() {
var test TestGetConversationListSplitCallBack
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetConversationListSplit(test, test.OperationID, 1, 2)
}
type TestGetOneConversationCallBack struct {
}
func (t TestGetOneConversationCallBack) OnError(errCode int32, errMsg string) {
fmt.Printf("TestGetOneConversationCallBack , errCode:%v,errMsg:%v\n", errCode, errMsg)
}
func (t TestGetOneConversationCallBack) OnSuccess(data string) {
fmt.Printf("TestGetOneConversationCallBack , success,data:%v\n", data)
}
func DoTestGetConversationRecvMessageOpt(list string) {
var test TestGetConversationRecvMessageOpt
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetConversationRecvMessageOpt(test, test.OperationID, list)
}
type TestGetConversationRecvMessageOpt struct {
OperationID string
}
func (t TestGetConversationRecvMessageOpt) OnError(errCode int32, errMsg string) {
fmt.Printf("TestGetConversationRecvMessageOpt , errCode:%v,errMsg:%v\n", errCode, errMsg)
}
func (t TestGetConversationRecvMessageOpt) OnSuccess(data string) {
fmt.Printf("TestGetConversationRecvMessageOpt , success,data:%v\n", data)
}
func DoTestCreateTextMessage(text string) string {
operationID := utils.OperationIDGenerator()
return open_im_sdk.CreateTextMessage(operationID, text)
}
func DoTestCreateImageMessageFromFullPath() string {
operationID := utils.OperationIDGenerator()
return open_im_sdk.CreateImageMessageFromFullPath(operationID, "C:\\Users\\Administrator\\Desktop\\rtc.proto")
//open_im_sdk.SendMessage(&testSendMsg, operationID, s, , "", utils.StructToJsonString(o))
}
func DoTestCreateOtherMessageFromFullPath() string {
operationID := utils.OperationIDGenerator()
return open_im_sdk.CreateFileMessageFromFullPath(operationID, "C:\\Users\\Administrator\\Desktop\\2.txt", "2.txt")
//open_im_sdk.SendMessage(&testSendMsg, operationID, s, , "", utils.StructToJsonString(o))
}
func DoTestCreateVideoMessageFromFullPath() string {
operationID := utils.OperationIDGenerator()
return open_im_sdk.CreateVideoMessageFromFullPath(operationID, "C:\\Users\\Administrator\\Desktop\\video_test.mp4", "mp4", 5, "C:\\Users\\Administrator\\Desktop\\shot.jpg")
}
// funcation DoTestSetConversationDraft() {
// var test TestSetConversationDraft
// open_im_sdk.SetConversationDraft("single_c93bc8b171cce7b9d1befb389abfe52f", "hah", test)
//
// }
type TestSetConversationDraft struct {
}
func (t TestSetConversationDraft) OnError(errCode int32, errMsg string) {
fmt.Printf("SetConversationDraft , OnError %v\n", errMsg)
}
func (t TestSetConversationDraft) OnSuccess(data string) {
fmt.Printf("SetConversationDraft , OnSuccess %v\n", data)
}
type GetHistoryCallBack struct {
OperationID string
Data string
}
func (g GetHistoryCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "GetHistoryCallBack err", "operationID", g.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (g GetHistoryCallBack) OnSuccess(data string) {
g.Data = data
log.ZInfo(ctx, "get History success ", "operationID", g.OperationID, "data", data)
}
type SetAppBadgeCallBack struct {
OperationID string
}
func (g SetAppBadgeCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "SetAppBadgeCallBack err", "operationID", g.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (g SetAppBadgeCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "SetAppBadgeCallBack success", "operationID", g.OperationID, "data", data)
}
type UpdateFcmTokenCallBack struct {
OperationID string
}
func (g UpdateFcmTokenCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "UpdateFcmTokenCallBack err", "operationID", g.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (g UpdateFcmTokenCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "UpdateFcmTokenCallBack success", "operationID", g.OperationID, "data", data)
}
type FindMessageListCallBack struct {
OperationID string
}
func (g FindMessageListCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "FindMessageListCallBack err", "operationID", g.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (g FindMessageListCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "FindMessageListCallBack success", "operationID", g.OperationID, "data", data)
}
type SetMessageReactionExtensionsCallBack struct {
OperationID string
}
func (g SetMessageReactionExtensionsCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "SetMessageReactionExtensionsCallBack err", "operationID", g.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (g SetMessageReactionExtensionsCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "SetMessageReactionExtensionsCallBack success", "operationID", g.OperationID, "data", data)
}
type AddMessageReactionExtensionsCallBack struct {
OperationID string
}
func (g AddMessageReactionExtensionsCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "AddMessageReactionExtensionsCallBack err", "operationID", g.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (g AddMessageReactionExtensionsCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "AddMessageReactionExtensionsCallBack success", "operationID", g.OperationID, "data", data)
}
type GetMessageListReactionExtensionsCallBack struct {
OperationID string
}
func (g GetMessageListReactionExtensionsCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, g.OperationID, "GetMessageListReactionExtensionsCallBack err", errCode, "errMsg", errMsg)
}
func (g GetMessageListReactionExtensionsCallBack) OnSuccess(data string) {
log.ZInfo(ctx, g.OperationID, "GetMessageListReactionExtensionsCallBack success", "data", data)
}
type GetHistoryReverseCallBack struct {
OperationID string
}
func (g GetHistoryReverseCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, g.OperationID, "GetHistoryReverseCallBack err", errCode, "errMsg", errMsg)
}
func (g GetHistoryReverseCallBack) OnSuccess(data string) {
log.ZInfo(ctx, g.OperationID, "GetHistoryReverseCallBack success", "data", data)
}
type SearchLocalMessagesCallBack struct {
OperationID string
}
func (g SearchLocalMessagesCallBack) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, g.OperationID, "SearchLocalMessagesCallBack err", errCode, "errMsg", errMsg)
}
func (g SearchLocalMessagesCallBack) OnSuccess(data string) {
fmt.Println(g.OperationID, "SearchLocalMessagesCallBack success", "data", data)
}
type MsgListenerCallBak struct {
}
func (m *MsgListenerCallBak) OnMsgDeleted(s string) {}
func (m *MsgListenerCallBak) OnRecvOfflineNewMessage(message string) {
//TODO implement me
panic("implement me")
}
func (m *MsgListenerCallBak) OnRecvMessageExtensionsAdded(msgID string, reactionExtensionList string) {
fmt.Printf("OnRecvMessageExtensionsAdded", msgID, reactionExtensionList)
log.ZInfo(ctx, "internal", "OnRecvMessageExtensionsAdded", "msgID", msgID, "reactionExtensionList", reactionExtensionList)
}
func (m *MsgListenerCallBak) OnRecvGroupReadReceipt(groupMsgReceiptList string) {
//fmt.Println("OnRecvC2CReadReceipt , ", groupMsgReceiptList)
}
func (m *MsgListenerCallBak) OnNewRecvMessageRevoked(messageRevoked string) {
//fmt.Println("OnNewRecvMessageRevoked , ", messageRevoked)
}
func (m *MsgListenerCallBak) OnRecvMessageExtensionsChanged(msgID string, reactionExtensionList string) {
log.ZInfo(ctx, "internal", "OnRecvMessageExtensionsChanged", "msgID", msgID, "reactionExtensionList", reactionExtensionList)
}
func (m *MsgListenerCallBak) OnRecvMessageExtensionsDeleted(msgID string, reactionExtensionKeyList string) {
log.ZInfo(ctx, "internal", "OnRecvMessageExtensionsDeleted", "msgID", msgID, "reactionExtensionKeyList", reactionExtensionKeyList)
}
func (m *MsgListenerCallBak) OnRecvOnlineOnlyMessage(message string) {
}
type BatchMsg struct {
}
func (m *BatchMsg) OnRecvNewMessages(groupMsgReceiptList string) {
log.ZInfo(ctx, "OnRecvNewMessages", "groupMsgReceiptList", groupMsgReceiptList)
}
func (m *BatchMsg) OnRecvOfflineNewMessages(messageList string) {
log.ZInfo(ctx, "OnRecvOfflineNewMessages", "messageList", messageList)
}
func (m *MsgListenerCallBak) OnRecvNewMessage(msg string) {
var mm sdk_struct.MsgStruct
err := json.Unmarshal([]byte(msg), &mm)
if err != nil {
log.ZError(ctx, "Unmarshal failed", err, "msg", msg)
} else {
RecvMsgMapLock.Lock()
defer RecvMsgMapLock.Unlock()
t := SendRecvTime{SendIDRecvID: mm.SendID + mm.RecvID, RecvTime: utils.GetCurrentTimestampByMill()}
RecvAllMsg[mm.ClientMsgID] = &t
log.ZInfo(ctx, "", "OnRecvNewMessage callback", "ClientMsgID", mm.ClientMsgID, "SendID", mm.SendID, "RecvID", mm.RecvID)
}
}
type TestSearchLocalMessages struct {
OperationID string
}
func (t TestSearchLocalMessages) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, t.OperationID, "SearchLocalMessages , OnError", "errCode", errCode, "errMsg", errMsg)
}
func (t TestSearchLocalMessages) OnSuccess(data string) {
log.ZInfo(ctx, t.OperationID, "SearchLocalMessages , OnSuccess", "data", data)
}
//funcation DoTestSearchLocalMessages() {
// var t TestSearchLocalMessages
// operationID := utils.OperationIDGenerator()
// t.OperationID = operationID
// var p sdk_params_callback.SearchLocalMessagesParams
// //p.SessionType = constant.SingleChatType
// p.SourceID = "18090680773"
// p.KeywordList = []string{}
// p.SearchTimePeriod = 24 * 60 * 60 * 10
// open_im_sdk.SearchLocalMessages(t, operationID, utils.StructToJsonString(p))
//}
type TestDeleteConversation struct {
OperationID string
}
func (t TestDeleteConversation) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, t.OperationID, "TestDeleteConversation , OnError", "errCode", errCode, "errMsg", errMsg)
}
func (t TestDeleteConversation) OnSuccess(data string) {
log.ZInfo(ctx, t.OperationID, "TestDeleteConversation , OnSuccess", "data", data)
}
func (m MsgListenerCallBak) OnRecvC2CReadReceipt(data string) {
fmt.Println("OnRecvC2CReadReceipt , ", data)
}
func (m MsgListenerCallBak) OnRecvMessageRevoked(msgId string) {
fmt.Println("OnRecvMessageRevoked ", msgId)
}
type conversationCallBack struct {
SyncFlag int
}
func (c *conversationCallBack) OnRecvMessageExtensionsChanged(msgID string, reactionExtensionList string) {
panic("implement me")
}
func (c *conversationCallBack) OnRecvMessageExtensionsDeleted(msgID string, reactionExtensionKeyList string) {
panic("implement me")
}
func (c *conversationCallBack) OnSyncServerProgress(progress int) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "progress", progress)
}
func (c *conversationCallBack) OnSyncServerStart() {
}
func (c *conversationCallBack) OnSyncServerFinish() {
c.SyncFlag = 1
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (c *conversationCallBack) OnSyncServerFailed() {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (c *conversationCallBack) OnNewConversation(conversationList string) {
log.ZInfo(ctx, "OnNewConversation returnList is", conversationList)
}
func (c *conversationCallBack) OnConversationChanged(conversationList string) {
log.ZInfo(ctx, "OnConversationChanged. ", "returnList is", conversationList)
}
func (c *conversationCallBack) OnTotalUnreadMessageCountChanged(totalUnreadCount int32) {
log.ZInfo(ctx, "OnTotalUnreadMessageCountChanged returnTotalUnreadCount is", totalUnreadCount)
}
func (c *conversationCallBack) OnConversationUserInputStatusChanged(change string) {
}
type testMarkC2CMessageAsRead struct {
}
func (testMarkC2CMessageAsRead) OnSuccess(data string) {
fmt.Println(" testMarkC2CMessageAsRead OnSuccess", data)
}
func (testMarkC2CMessageAsRead) OnError(code int32, msg string) {
fmt.Println("testMarkC2CMessageAsRead, OnError", code, msg)
}
//funcation DoTestMarkC2CMessageAsRead() {
// var test testMarkC2CMessageAsRead
// readid := "2021-06-23 12:25:36-7eefe8fc74afd7c6adae6d0bc76929e90074d5bc-8522589345510912161"
// var xlist []string
// xlist = append(xlist, readid)
// jsonid, _ := json.Marshal(xlist)
// open_im_sdk.MarkC2CMessageAsRead(test, Friend_uid, string(jsonid))
//}
type SendRecvTime struct {
SendTime int64
SendSeccCallbackTime int64
RecvTime int64
SendIDRecvID string
}
var SendSuccAllMsg map[string]*SendRecvTime //msgid->send+recv:
var SendFailedAllMsg map[string]string
var RecvAllMsg map[string]*SendRecvTime //msgid->send+recv
var SendMsgMapLock sync.RWMutex
var RecvMsgMapLock sync.RWMutex
func init() {
SendSuccAllMsg = make(map[string]*SendRecvTime)
SendFailedAllMsg = make(map[string]string)
RecvAllMsg = make(map[string]*SendRecvTime)
}
func DoTestSetAppBackgroundStatus(isBackground bool) {
var testSendMsg TestSendMsgCallBack
operationID := utils.OperationIDGenerator()
open_im_sdk.SetAppBackgroundStatus(&testSendMsg, operationID, isBackground)
}
func DoTestSendMsg2(sendId, recvID string) {
m := "Single chat test" + sendId + ":" + recvID + ":"
operationID := utils.OperationIDGenerator()
s := DoTestCreateTextMessage(m)
log.ZInfo(ctx, "send msg:", "operationID", operationID, "message", s) // 修改此行
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
o := sdkws.OfflinePushInfo{}
o.Title = "121313"
o.Desc = "45464"
open_im_sdk.SendMessage(&testSendMsg, operationID, s, recvID, "", utils.StructToJsonString(o), false)
log.ZInfo(ctx, utils.GetSelfFuncName(), "success", "sendId", sendId, "recvID", recvID) // 修改此行
}
func DoTestSendMsg2Group(sendId, groupID string, index int) {
m := "test: " + sendId + " : " + groupID + " : " + utils.IntToString(index)
operationID := utils.OperationIDGenerator()
s := DoTestCreateTextMessage(m)
log.ZInfo(ctx, "send msg:", "operationID", operationID, "message", s) // 修改此行
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
o := sdkws.OfflinePushInfo{}
o.Title = "Title"
o.Desc = "Desc"
open_im_sdk.SendMessage(&testSendMsg, operationID, s, "", groupID, utils.StructToJsonString(o), false)
log.ZInfo(ctx, utils.GetSelfFuncName(), "success") // 修改此行
}
func DoTestSendMsg2GroupWithMessage(sendId, groupID string, message string) {
operationID := utils.OperationIDGenerator()
s := DoTestCreateTextMessage(message)
log.ZInfo(ctx, "send msg:", "operationID", operationID, "message", s) // 修改此行
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
o := sdkws.OfflinePushInfo{}
o.Title = "Title"
o.Desc = "Desc"
open_im_sdk.SendMessage(&testSendMsg, operationID, s, "", groupID, utils.StructToJsonString(o), false)
log.ZInfo(ctx, utils.GetSelfFuncName(), "success") // 修改此行
}
func DoTestSendMsg2c2c(sendId, recvID string, index int) {
m := "test: " + sendId + " : " + recvID + " : " + utils.IntToString(index)
operationID := utils.OperationIDGenerator()
s := DoTestCreateTextMessage(m)
log.ZInfo(ctx, "send msg:", "operationID", operationID, "message", s) // 修改此行
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
o := sdkws.OfflinePushInfo{}
o.Title = "Title"
o.Desc = "Desc"
open_im_sdk.SendMessage(&testSendMsg, operationID, s, recvID, "", utils.StructToJsonString(o), false)
log.ZInfo(ctx, utils.GetSelfFuncName(), "success") // 修改此行
}
type TestMarkGroupMessageAsRead struct {
OperationID string
}
func (t TestMarkGroupMessageAsRead) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "TestMarkGroupMessageAsRead , OnError", "operationID", t.OperationID, "errMsg", errMsg) // 修改此行
}
func (t TestMarkGroupMessageAsRead) OnSuccess(data string) {
log.ZInfo(ctx, "TestMarkGroupMessageAsRead , OnSuccess", "operationID", t.OperationID, "data", data) // 修改此行
}
func DoTestSendMsg(index int, sendId, recvID string, groupID string, idx string) {
m := "test msg " + sendId + ":" + recvID + ":" + idx
operationID := utils.OperationIDGenerator()
ctx := mcontext.NewCtx(operationID)
s, err := allLoginMgr[index].mgr.Conversation().CreateTextMessage(ctx, m)
if err != nil {
log.ZError(ctx, "CreateTextMessage", err, "operationID", operationID)
return
}
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
testSendMsg.sendTime = utils.GetCurrentTimestampByMill()
o := sdkws.OfflinePushInfo{}
o.Title = "title"
o.Desc = "desc"
testSendMsg.sendID = sendId
testSendMsg.recvID = recvID
testSendMsg.groupID = groupID
testSendMsg.msgID = s.ClientMsgID
log.ZInfo(ctx, "SendMessage", "operationID", operationID, "sendId", sendId, "recvID", recvID, "groupID", groupID, "msgID",
testSendMsg.msgID, "index", index)
if recvID != "" {
allLoginMgr[index].mgr.Conversation().SendMessage(ctx, s, recvID, "", &o, false)
} else {
allLoginMgr[index].mgr.Conversation().SendMessage(ctx, s, "", groupID, &o, false)
}
SendMsgMapLock.Lock()
defer SendMsgMapLock.Unlock()
x := SendRecvTime{SendTime: utils.GetCurrentTimestampByMill()}
SendSuccAllMsg[testSendMsg.msgID] = &x
}
//
//funcation DoTestSendMsgPress(index int, sendId, recvID string, idx string) {
// m := "test msg " + sendId + ":" + recvID + ":" + idx
// operationID := utils.OperationIDGenerator()
// s := DoTestCreateTextMessageReliability(allLoginMgr[index].mgr, m)
// var mstruct sdk_struct.MsgStruct
// _ = json.Unmarshal([]byte(s), &mstruct)
//
// var testSendMsg TestSendMsgCallBackPress
// testSendMsg.OperationID = operationID
// o := server_api_params.OfflinePushInfo{}
// o.Title = "title"
// o.Desc = "desc"
// testSendMsg.sendID = sendId
// testSendMsg.recvID = recvID
// testSendMsg.msgID = mstruct.ClientMsgID
//
// log.Warn(operationID, "SendMessage", sendId, recvID, testSendMsg.msgID, index)
//
// allLoginMgr[index].mgr.Conversation().SendMessage(&testSendMsg, s, recvID, "", utils.StructToJsonString(o), operationID)
//}
func DoTestSendImageMsg(recvID string) {
operationID := utils.OperationIDGenerator()
s := DoTestCreateImageMessageFromFullPath()
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
o := sdkws.OfflinePushInfo{}
o.Title = "121313"
o.Desc = "45464"
open_im_sdk.SendMessage(&testSendMsg, operationID, s, recvID, "", utils.StructToJsonString(o), false)
}
//funcation DotestUploadFile() {
// operationID := utils.OperationIDGenerator()
// var testSendMsg TestSendMsgCallBack
// open_im_sdk.UploadFile(&testSendMsg, operationID, "C:\\Users\\Administrator\\Desktop\\video_test.mp4")
//}
func DoTestSendOtherMsg(sendId, recvID string) {
operationID := utils.OperationIDGenerator()
s := DoTestCreateOtherMessageFromFullPath()
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
o := sdkws.OfflinePushInfo{}
o.Title = "121313"
o.Desc = "45464"
open_im_sdk.SendMessage(&testSendMsg, operationID, s, recvID, "", utils.StructToJsonString(o), false)
}
func DoTestSendVideo(sendId, recvID string) {
operationID := utils.OperationIDGenerator()
s := DoTestCreateVideoMessageFromFullPath()
var testSendMsg TestSendMsgCallBack
testSendMsg.OperationID = operationID
o := sdkws.OfflinePushInfo{}
o.Title = "121313"
o.Desc = "45464"
log.ZInfo(ctx, "SendMessage", "operationID", operationID, "message", s)
open_im_sdk.SendMessage(&testSendMsg, operationID, s, recvID, "", utils.StructToJsonString(o), false)
}
type TestClearMsg struct {
OperationID string
}
func (t *TestClearMsg) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "TestClearMsg OnError", "operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (t *TestClearMsg) OnSuccess(data string) {
log.ZInfo(ctx, "TestClearMsg OnSuccess", "operationID", t.OperationID, "data", data)
}
func DoTestClearMsg() {
var test TestClearMsg
operationID := utils.OperationIDGenerator()
open_im_sdk.DeleteAllMsgFromLocalAndSvr(&test, operationID)
}
type TestModifyGroupMessageReaction struct {
OperationID string
}
func (t *TestModifyGroupMessageReaction) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "TestModifyGroupMessageReaction OnError", "operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func (t *TestModifyGroupMessageReaction) OnSuccess(data string) {
log.ZInfo(ctx, "TestModifyGroupMessageReaction OnSuccess", "operationID", t.OperationID, "data", data)
}
func DoTestGetSelfUserInfo() {
var test TestModifyGroupMessageReaction
open_im_sdk.GetSelfUserInfo(&test, "s")
}

View File

@@ -0,0 +1,792 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"encoding/json"
"errors"
"fmt"
"github.com/openimsdk/openim-sdk-core/v3/open_im_sdk"
"github.com/openimsdk/openim-sdk-core/v3/pkg/ccontext"
"github.com/openimsdk/openim-sdk-core/v3/pkg/sdk_params_callback"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/openim-sdk-core/v3/sdk_struct"
"github.com/openimsdk/tools/log"
X "log"
"os"
"runtime"
"time"
"github.com/openimsdk/protocol/sdkws"
"github.com/openimsdk/tools/mcontext"
)
var loggerf *X.Logger
func init() {
loggerf = X.New(os.Stdout, "", X.Llongfile|X.Ltime|X.Ldate)
}
type TestSendImg struct {
}
func (TestSendImg) OnSuccess(data string) {
fmt.Println("testSendImg, OnSuccess, output: ", data)
}
func (TestSendImg) OnError(code int, msg string) {
fmt.Println("testSendImg, OnError, ", code, msg)
}
func (TestSendImg) OnProgress(progress int) {
fmt.Println("progress: ", progress)
}
func TestLog(v ...interface{}) {
//X.SetFlags(X.Lshortfile | X.LstdFlags)
loggerf.Println(v)
a, b, c, d := runtime.Caller(1)
X.Println(a, b, c, d)
}
var Friend_uid = "3126758667"
func SetTestFriendID(friendUserID string) {
Friend_uid = friendUserID
}
///////////////////////////////////////////////////////////
type testGetFriendApplicationList struct {
baseCallback
}
func DoTestGetFriendApplicationList() {
var test testGetFriendApplicationList
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, test.OperationID, utils.GetSelfFuncName(), "input ")
// open_im_sdk.GetRecvFriendApplicationList(test, test.OperationID)
}
// ////////////////////////////////////////////////////////`
type testSetSelfInfo struct {
baseCallback
}
func DoTestSetSelfInfo() {
var test testSetSelfInfo
test.OperationID = utils.OperationIDGenerator()
userInfo := sdkws.UserInfo{}
userInfo.Nickname = "new 4444444444444 Gordon001"
jsonString := utils.StructToJsonStringDefault(userInfo)
fmt.Println("SetSelfInfo, input: ")
open_im_sdk.SetSelfInfo(test, test.OperationID, jsonString)
}
// ///////////////////////////////////////////////////////
type testGetUsersInfo struct {
baseCallback
}
func DoTestGetUsersInfo() {
var test testGetUsersInfo
test.OperationID = utils.OperationIDGenerator()
userIDList := []string{"4950399653"}
list := utils.StructToJsonStringDefault(userIDList)
fmt.Println("testGetUsersInfo, input: ", list)
open_im_sdk.GetUsersInfo(test, test.OperationID, list)
}
// ///////////////////////////////////////////////////////
type testGetFriendsInfo struct {
uid []string //`json:"uidList"`
}
func (testGetFriendsInfo) OnSuccess(data string) {
fmt.Println("DoTestGetDesignatedFriendsInfo, OnSuccess, output: ", data)
}
func (testGetFriendsInfo) OnError(code int32, msg string) {
fmt.Println("DoTestGetDesignatedFriendsInfo, OnError, ", code, msg)
}
func DoTestGetDesignatedFriendsInfo() {
var test testGetFriendsInfo
test.uid = append(test.uid, Friend_uid)
jsontest, _ := json.Marshal(test.uid)
fmt.Println("testGetFriendsInfo, input: ", string(jsontest))
// open_im_sdk.GetDesignatedFriendsInfo(test, "xxxxxxxxxxx", string(jsontest))
}
// /////////////////////////////////////////////////////
type testAddToBlackList struct {
OperationID string
}
func (t testAddToBlackList) OnSuccess(string) {
log.ZInfo(ctx, t.OperationID, "testAddToBlackList, OnSuccess")
}
func (t testAddToBlackList) OnError(code int32, msg string) {
log.ZInfo(ctx, t.OperationID, "testAddToBlackList, OnError, ", code, msg)
}
func DoTestAddToBlackList(userID string) {
var test testAddToBlackList
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.AddBlack(test, test.OperationID, userID, "")
}
// /////////////////////////////////////////////////////
type testDeleteFromBlackList struct {
baseCallback
}
func DoTestDeleteFromBlackList(userID string) {
var test testDeleteFromBlackList
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.RemoveBlack(test, test.OperationID, userID)
}
// ////////////////////////////////////////////////////
type testGetBlackList struct {
OperationID string
}
func (t testGetBlackList) OnSuccess(data string) {
log.ZInfo(ctx, t.OperationID, "testGetBlackList, OnSuccess, output: ", data)
}
func (t testGetBlackList) OnError(code int32, msg string) {
log.ZInfo(ctx, t.OperationID, "testGetBlackList, OnError, ", code, msg)
}
func DoTestGetBlackList() {
var test testGetBlackList
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetBlackList(test, test.OperationID)
}
//////////////////////////////////////////////////////
type testCheckFriend struct {
OperationID string
}
func (t testCheckFriend) OnSuccess(data string) {
log.ZInfo(ctx, t.OperationID, "testCheckFriend, OnSuccess, output: ", data)
}
func (t testCheckFriend) OnError(code int32, msg string) {
log.ZInfo(ctx, t.OperationID, "testCheckFriend, OnError, ", code, msg)
}
func DoTestCheckFriend() {
var test testCheckFriend
test.OperationID = utils.OperationIDGenerator()
userIDList := []string{"openIM100"}
list := utils.StructToJsonString(userIDList)
fmt.Println("CheckFriend, input: ", list)
open_im_sdk.CheckFriend(test, test.OperationID, list)
}
// /////////////////////////////////////////////////////////
type testSetFriendRemark struct {
baseCallback
}
func DotestSetFriendRemark() {
var test testSetFriendRemark
test.OperationID = utils.OperationIDGenerator()
var param sdk_params_callback.SetFriendRemarkParams
param.ToUserID = Friend_uid
param.Remark = "4444 "
jsontest := utils.StructToJsonString(param)
log.ZInfo(ctx, test.OperationID, utils.GetSelfFuncName(), "input ", jsontest)
open_im_sdk.SetFriendRemark(test, test.OperationID, jsontest)
}
/////////////////////
////////////////////////////////////////////////////////
type testDeleteFriend struct {
baseCallback
}
func DotestDeleteFriend(userID string) {
var test testDeleteFriend
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.DeleteFriend(test, test.OperationID, userID)
}
// /////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////
type testaddFriend struct {
OperationID string
}
func (t testaddFriend) OnSuccess(data string) {
log.ZInfo(ctx, t.OperationID, "testaddFriend, OnSuccess", data)
}
func (t testaddFriend) OnError(code int32, msg string) {
log.ZInfo(ctx, t.OperationID, "testaddFriend, OnError", code, msg)
}
func DoTestAddFriend() {
var test testaddFriend
test.OperationID = utils.OperationIDGenerator()
params := sdk_params_callback.AddFriendParams{
ToUserID: Friend_uid,
ReqMsg: "777777777777777777777777",
}
jsontestaddFriend := utils.StructToJsonString(params)
log.ZInfo(ctx, test.OperationID, "addFriend input:", jsontestaddFriend)
open_im_sdk.AddFriend(test, test.OperationID, jsontestaddFriend)
}
////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////
type testGetSendFriendApplicationList struct {
OperationID string
}
func (t testGetSendFriendApplicationList) OnSuccess(data string) {
log.ZInfo(ctx, t.OperationID, "testGetSendFriendApplicationList, OnSuccess", data)
}
func (t testGetSendFriendApplicationList) OnError(code int32, msg string) {
log.ZInfo(ctx, t.OperationID, "testGetSendFriendApplicationList, OnError", code, msg)
}
func DoTestGetSendFriendApplicationList() {
var test testGetSendFriendApplicationList
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, test.OperationID, "GetSendFriendApplicationList input:")
// open_im_sdk.GetSendFriendApplicationList(test, test.OperationID)
}
////////////////////////////////////////////////////////////////////
type testGetFriendList struct {
baseCallback
}
func DotestGetFriendList() {
var test testGetFriendList
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, test.OperationID, utils.GetSelfFuncName(), "input ")
open_im_sdk.GetFriendList(test, test.OperationID)
}
type testSearchFriends struct {
baseCallback
}
func DotestSearchFriends() {
var test testSearchFriends
test.OperationID = utils.OperationIDGenerator()
test.callName = "SearchFriends"
var params sdk_params_callback.SearchFriendsParam
params.KeywordList = []string{"G"}
params.IsSearchUserID = true
params.IsSearchNickname = true
params.IsSearchRemark = true
log.ZInfo(ctx, test.OperationID, utils.GetSelfFuncName(), "input ", params)
open_im_sdk.SearchFriends(test, test.OperationID, utils.StructToJsonString(params))
}
/////////////////////////////////////////////////////////////////////
type testAcceptFriendApplication struct {
baseCallback
}
func DoTestAcceptFriendApplication() {
var test testAcceptFriendApplication
test.OperationID = utils.OperationIDGenerator()
var param sdk_params_callback.ProcessFriendApplicationParams
param.HandleMsg = "ok ok "
param.ToUserID = Friend_uid
input := utils.StructToJsonString(param)
open_im_sdk.AcceptFriendApplication(test, test.OperationID, input)
}
type testRefuseFriendApplication struct {
baseCallback
}
func DoTestRefuseFriendApplication() {
var test testRefuseFriendApplication
test.OperationID = utils.OperationIDGenerator()
var param sdk_params_callback.ProcessFriendApplicationParams
param.HandleMsg = "nonono"
param.ToUserID = Friend_uid
input := utils.StructToJsonString(param)
open_im_sdk.RefuseFriendApplication(test, test.OperationID, input)
}
/*
type testRefuseFriendApplication struct {
ui2AcceptFriend
}
func (testRefuseFriendApplication) OnSuccess(info string) {
fmt.Println("RefuseFriendApplication OnSuccess", info)
}
func (testRefuseFriendApplication) OnError(code int, msg string) {
fmt.Println("RefuseFriendApplication, OnError, ", code, msg)
}
*/
/*
func DoTestRefuseFriendApplication() {
var test testRefuseFriendApplication
test.UID = Friend_uid
js, _ := json.Marshal(test)
RefuseFriendApplication(test, string(js))
fmt.Println("RefuseFriendApplication, input: ", string(js))
}
*/
/////////////////////////////////////////////////////////////////////
//type testRefuseFriendApplication struct {
// open_im_sdk.ui2AcceptFriend
//}
//
//func (testRefuseFriendApplication) OnSuccess(info string) {
// fmt.Println("testRefuseFriendApplication OnSuccess", info)
//}
//func (testRefuseFriendApplication) OnError(code int32, msg string) {
// fmt.Println("testRefuseFriendApplication, OnError, ", code, msg)
//}
//func DoTestRefuseFriendApplication() {
// var testRefuseFriendApplication testRefuseFriendApplication
// testRefuseFriendApplication.ui2AcceptFriend = Friend_uid
//
// jsontestfusetFriendappclicatrion, _ := json.Marshal(testRefuseFriendApplication.UID)
// open_im_sdk.RefuseFriendApplication(testRefuseFriendApplication, string(jsontestfusetFriendappclicatrion), "")
// fmt.Println("RefuseFriendApplication, input: ", string(jsontestfusetFriendappclicatrion))
//}
////////////////////////////////////////////////////////////////////
func SetListenerAndLogin(uid, tk string) {
//
//var testConversation conversationCallBack
//open_im_sdk.SetConversationListener(&testConversation)
//
//var testUser userCallback
//open_im_sdk.SetUserListener(testUser)
//
//var msgCallBack MsgListenerCallBak
//open_im_sdk.SetAdvancedMsgListener(&msgCallBack)
//
//var batchMsg BatchMsg
//open_im_sdk.SetBatchMsgListener(&batchMsg)
//
//var friendListener testFriendListener
//open_im_sdk.SetFriendListener(friendListener)
//
//var groupListener testGroupListener
//open_im_sdk.SetGroupListener(groupListener)
//var signalingListener testSignalingListener
//open_im_sdk.SetSignalingListener(&signalingListener)
//
//var organizationListener testOrganizationListener
//open_im_sdk.SetOrganizationListener(organizationListener)
//
//var workMomentsListener testWorkMomentsListener
//open_im_sdk.SetWorkMomentsListener(workMomentsListener)
//InOutlllogin(uid, tk)
log.ZWarn(ctx, "SetListenerAndLogin fin", errors.New(""))
}
func lllogin(uid, tk string) bool {
var callback BaseSuccessFailed
callback.funcName = utils.GetSelfFuncName()
operationID := utils.OperationIDGenerator()
open_im_sdk.Login(&callback, uid, operationID, tk)
for true {
if callback.errCode == 1 {
fmt.Println("success code 1")
return true
} else if callback.errCode == -1 {
fmt.Println("failed code -1")
return false
} else {
fmt.Println("code sleep")
time.Sleep(1 * time.Second)
continue
}
}
return true
}
func ReliabilityInitAndLogin(index int, uid, tk, ws, api string) {
var cf sdk_struct.IMConfig
cf.ApiAddr = api
cf.WsAddr = ws
cf.PlatformID = 1
cf.DataDir = "./"
cf.IsLogStandardOutput = true
cf.LogLevel = uint32(LogLevel)
operationID := utils.OperationIDGenerator()
ctx := mcontext.NewCtx(operationID)
var testinit testInitLister
lg := new(open_im_sdk.LoginMgr)
log.ZInfo(ctx, "DoReliabilityTest", "UID", uid, "Token", tk, "WS", ws, "API", api)
log.ZInfo(ctx, "New login manager ", "OperationID", operationID)
allLoginMgr[index].mgr = lg
lg.InitSDK(cf, &testinit)
ctx = ccontext.WithOperationID(lg.Context(), operationID)
log.ZInfo(ctx, "Initialized SDK with config", "Config", cf)
var testConversation conversationCallBack
lg.SetConversationListener(&testConversation)
var testUser userCallback
lg.SetUserListener(testUser)
var msgCallBack MsgListenerCallBak
lg.SetAdvancedMsgListener(&msgCallBack)
var friendListener testFriendListener
lg.SetFriendListener(friendListener)
var groupListener testGroupListener
lg.SetGroupListener(groupListener)
var callback BaseSuccessFailed
callback.funcName = utils.GetSelfFuncName()
for {
if callback.errCode == 1 && testConversation.SyncFlag == 1 {
lg.User().GetSelfUserInfo(ctx)
return
}
}
}
func PressInitAndLogin(index int, uid, tk, ws, api string) {
var cf sdk_struct.IMConfig
cf.ApiAddr = api
cf.WsAddr = ws
cf.PlatformID = 1
cf.DataDir = "./"
cf.LogLevel = uint32(LogLevel)
operationID := utils.OperationIDGenerator()
ctx := mcontext.NewCtx(operationID)
var testinit testInitLister
lg := new(open_im_sdk.LoginMgr)
log.ZInfo(ctx, "DoReliabilityTest", "UID", uid, "Token", tk, "WS", ws, "API", api)
log.ZInfo(ctx, "New login manager ", "OperationID", operationID)
allLoginMgr[index].mgr = lg
lg.InitSDK(cf, &testinit)
log.ZInfo(ctx, "Initialized SDK with config", "Config", cf)
var testConversation conversationCallBack
lg.SetConversationListener(&testConversation)
var testUser userCallback
lg.SetUserListener(testUser)
var msgCallBack MsgListenerCallBak
lg.SetAdvancedMsgListener(&msgCallBack)
var friendListener testFriendListener
lg.SetFriendListener(friendListener)
var groupListener testGroupListener
lg.SetGroupListener(groupListener)
err := lg.Login(ctx, uid, tk)
if err != nil {
log.ZError(ctx, "Login failed", err, "OperationID", operationID)
}
}
func DoTest(uid, tk, ws, api string) {
var cf sdk_struct.IMConfig
cf.ApiAddr = api // "http://120.24.45.199:10000"
cf.WsAddr = ws //"ws://120.24.45.199:17778"
cf.PlatformID = 1
cf.DataDir = "./"
var s string
b, _ := json.Marshal(cf)
s = string(b)
fmt.Println(s)
var testinit testInitLister
operationID := utils.OperationIDGenerator()
if !open_im_sdk.InitSDK(&testinit, operationID, s) {
log.ZError(ctx, "InitSDK failed", errors.New("InitSDK failed"))
return
}
var testConversation conversationCallBack
open_im_sdk.SetConversationListener(&testConversation)
var testUser userCallback
open_im_sdk.SetUserListener(testUser)
//var msgCallBack MsgListenerCallBak
//open_im_sdk.AddAdvancedMsgListener(msgCallBack)
var friendListener testFriendListener
open_im_sdk.SetFriendListener(friendListener)
var groupListener testGroupListener
open_im_sdk.SetGroupListener(groupListener)
time.Sleep(1 * time.Second)
for !lllogin(uid, tk) {
fmt.Println("lllogin, failed, login...")
time.Sleep(1 * time.Second)
}
}
////////////////////////////////////////////////////////////////////
type TestSendMsgCallBack struct {
msg string
OperationID string
sendID string
recvID string
msgID string
sendTime int64
recvTime int64
groupID string
}
func (t *TestSendMsgCallBack) OnError(errCode int32, errMsg string) {
log.ZError(ctx, "test_openim: send msg failed: ", errors.New("test_openim: send msg failed: "),
"operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg, "msgID", t.msgID, "msg", t.msg)
SendMsgMapLock.Lock()
defer SendMsgMapLock.Unlock()
SendFailedAllMsg[t.msgID] = t.sendID + t.recvID
}
func (t *TestSendMsgCallBack) OnSuccess(data string) {
log.ZInfo(ctx, "test_openim: send msg success: |", "operationID", t.OperationID,
"msgID", t.msgID, "msg", t.msg, "data", data)
SendMsgMapLock.Lock()
defer SendMsgMapLock.Unlock()
//k, _ := SendSuccAllMsg[t.msgID]
//k.SendSeccCallbackTime = utils.GetCurrentTimestampByMill()
//k.SendIDRecvID = t.sendID + t.recvID
}
func (t *TestSendMsgCallBack) OnProgress(progress int) {
// fmt.Printf("msg_send , onProgress %d\n", progress)
}
type TestSendMsgCallBackPress struct {
msg string
OperationID string
sendID string
recvID string
msgID string
}
func (t *TestSendMsgCallBackPress) OnError(errCode int32, errMsg string) {
log.ZWarn(ctx, "TestSendMsgCallBackPress: send msg failed: |", errors.New(""), "operationID", t.OperationID, "errCode",
errCode, "errMsg", errMsg, "msgID", t.msgID, "msg", t.msg)
}
func (t *TestSendMsgCallBackPress) OnSuccess(data string) {
log.ZInfo(ctx, "TestSendMsgCallBackPress: send msg success: |", "operationID", t.OperationID, "msgID", t.msgID, "msg", t.msg)
}
func (t *TestSendMsgCallBackPress) OnProgress(progress int) {
// fmt.Printf("msg_send , onProgress %d\n", progress)
}
type BaseSuccessFailedTest struct {
successData string
errCode int
errMsg string
funcName string
}
func (b *BaseSuccessFailedTest) OnError(errCode int32, errMsg string) {
b.errCode = -1
b.errMsg = errMsg
fmt.Println("22onError ", b.funcName, errCode, errMsg)
}
func (b *BaseSuccessFailedTest) OnSuccess(data string) {
b.errCode = 1
b.successData = data
fmt.Println("22OnSuccess: ", b.funcName, data)
}
func InOutDoTestSendMsg(sendId, receiverID string) {
m := "test:" + sendId + ":" + receiverID + ":"
//s := CreateTextMessage(m)
var testSendMsg TestSendMsgCallBack
// testSendMsg.msg = SendMessage(&testSendMsg, s, receiverID, "", false)
fmt.Println("func send ", m, testSendMsg.msg)
fmt.Println("test to recv : ", receiverID)
}
//func DoTestGetAllConversationList() {
// var test TestGetAllConversationListCallBack
// open_im_sdk.GetAllConversationList(test)
//}
type userCallback struct {
}
func (c userCallback) OnUserStatusChanged(statusMap string) {
log.ZInfo(ctx, "User Status Changed", "statusMap", statusMap)
}
func (userCallback) OnSelfInfoUpdated(callbackData string) {
log.ZInfo(ctx, "Self Info Updated", "callbackData", callbackData)
}
func (userCallback) OnUserCommandAdd(callbackData string) {
log.ZInfo(ctx, "User Command Added", "callbackData", callbackData)
}
func (userCallback) OnUserCommandUpdate(callbackData string) {
log.ZInfo(ctx, "User Command Updated", "callbackData", callbackData)
}
func (userCallback) OnUserCommandDelete(callbackData string) {
log.ZInfo(ctx, "User Command Deleted", "callbackData", callbackData)
}
// //////////////////////////////////////////////////////////////////
type testInitLister struct {
}
func (t *testInitLister) OnUserTokenInvalid(errMsg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "errMsg", errMsg)
}
func (t *testInitLister) OnUserTokenExpired() {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnConnecting() {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnConnectSuccess() {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnConnectFailed(ErrCode int32, ErrMsg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "errCode", ErrCode, "errMsg", ErrMsg)
}
func (t *testInitLister) OnKickedOffline() {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnSelfInfoUpdated(info string) {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnUserCommandAdd(info string) {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnUserCommandDelete(info string) {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnUserCommandUpdates(info string) {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnSuccess() {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (t *testInitLister) OnError(code int32, msg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "code", code, "msg", msg)
}
type testLogin struct {
}
func (testLogin) OnSuccess(string) {
fmt.Println("testLogin OnSuccess")
}
func (testLogin) OnError(code int32, msg string) {
fmt.Println("testLogin, OnError", code, msg)
}
type testFriendListener struct {
x int
}
func (testFriendListener) OnFriendApplicationAdded(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnFriendApplicationDeleted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnFriendApplicationAccepted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnFriendApplicationRejected(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnFriendAdded(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnFriendDeleted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnBlackAdded(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnBlackDeleted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnFriendInfoChanged(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo)
}
func (testFriendListener) OnSuccess() {
log.ZInfo(ctx, utils.GetSelfFuncName())
}
func (testFriendListener) OnError(code int32, msg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "Code", code, "Message", msg)
}

View File

@@ -0,0 +1,533 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"github.com/openimsdk/openim-sdk-core/v3/open_im_sdk"
"github.com/openimsdk/openim-sdk-core/v3/pkg/constant"
"github.com/openimsdk/openim-sdk-core/v3/pkg/sdk_params_callback"
"github.com/openimsdk/openim-sdk-core/v3/pkg/server_api_params"
// "encoding/json"
"fmt"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/tools/log"
//"open_im_sdk/internal/open_im_sdk"
//"open_im_sdk/pkg/utils"
// "open_im_sdk/internal/common"
)
type XBase struct {
}
func (XBase) OnError(errCode int32, errMsg string) {
fmt.Println("get groupmenberinfo OnError", errCode, errMsg)
}
func (XBase) OnSuccess(data string) {
fmt.Println("get groupmenberinfo OnSuccess, ", data)
}
func (XBase) OnProgress(progress int) {
fmt.Println("OnProgress, ", progress)
}
type testGroupListener struct {
}
func (testGroupListener) OnJoinedGroupAdded(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnJoinedGroupDeleted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupMemberAdded(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupMemberDeleted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupApplicationAdded(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupApplicationDeleted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupInfoChanged(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupMemberInfoChanged(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupApplicationAccepted(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupApplicationRejected(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
func (testGroupListener) OnGroupDismissed(callbackInfo string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "CallbackInfo", callbackInfo, "operationID", utils.OperationIDGenerator())
}
type testOrganizationListener struct {
}
func (testOrganizationListener) OnOrganizationUpdated() {
log.ZInfo(ctx, utils.GetSelfFuncName(), "on listener callback", "operationID", utils.OperationIDGenerator())
}
type testWorkMomentsListener struct {
}
func (testWorkMomentsListener) OnRecvNewNotification() {
log.ZInfo(ctx, utils.GetSelfFuncName(), "on listener callback", "operationID", utils.OperationIDGenerator())
}
type testCreateGroup struct {
OperationID string
}
func (t testCreateGroup) OnSuccess(data string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "Data", data)
}
func (t testCreateGroup) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "ErrorCode", errCode, "ErrorMsg", errMsg)
}
func SetTestGroupID(groupID, memberID string) {
MemberUserID = memberID
TestgroupID = groupID
}
var MemberUserID = "2101502031"
var me = "3984071717"
var TestgroupID = "3109164461"
func DoTestCreateGroup() {
var test testCreateGroup
test.OperationID = utils.OperationIDGenerator()
var groupInfo sdk_params_callback.CreateGroupBaseInfoParam
groupInfo.GroupName = "聊聊大群测试"
groupInfo.GroupType = 1
var memberlist []server_api_params.GroupAddMemberInfo
memberlist = append(memberlist, server_api_params.GroupAddMemberInfo{UserID: MemberUserID, RoleLevel: 1})
memberlist = append(memberlist, server_api_params.GroupAddMemberInfo{UserID: me, RoleLevel: 2})
g1 := utils.StructToJsonString(groupInfo)
g2 := utils.StructToJsonString(memberlist)
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID: ", test.OperationID, "g1", g1, "g2", g2)
// open_im_sdk.CreateGroup(test, test.OperationID, g1, g2)
}
type testSetGroupInfo struct {
OperationID string
}
func (t testSetGroupInfo) OnSuccess(data string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "data", data)
}
func (t testSetGroupInfo) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func DoSetGroupInfo() {
var test testSetGroupInfo
operationID := utils.OperationIDGenerator()
test.OperationID = operationID
var input sdk_params_callback.SetGroupInfoParam
input.GroupName = "new group name 11111111"
input.Notification = "new notification 11111"
var n int32
n = 1
input.NeedVerification = &n
setInfo := utils.StructToJsonString(input)
// open_im_sdk.SetGroupInfo(test, operationID, TestgroupID, setInfo)
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", operationID, "input: ", setInfo)
}
func DoSetGroupVerification() {
var test testSetGroupInfo
operationID := utils.OperationIDGenerator()
test.OperationID = operationID
open_im_sdk.SetGroupVerification(test, operationID, TestgroupID, 1)
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", operationID, "input: ", TestgroupID, 2)
}
func DoSetGroupLookMemberInfo() {
var test testSetGroupInfo
operationID := utils.OperationIDGenerator()
test.OperationID = operationID
open_im_sdk.SetGroupLookMemberInfo(test, operationID, TestgroupID, 0)
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", operationID, "input: ", TestgroupID, 1)
}
func DoSetGroupApplyMemberFriend() {
var test testSetGroupInfo
operationID := utils.OperationIDGenerator()
test.OperationID = operationID
open_im_sdk.SetGroupApplyMemberFriend(test, operationID, TestgroupID, 1)
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", operationID, "input: ", TestgroupID, 1)
}
type testGetGroupsInfo struct {
OperationID string
}
func (t testGetGroupsInfo) OnSuccess(data string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "testGetGroupsInfo,onSuccess", data)
}
func (t testGetGroupsInfo) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "testGetGroupsInfo,onError", errCode, errMsg)
}
type testSearchGroups struct {
OperationID string
}
func (t testSearchGroups) OnSuccess(data string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "data", data)
}
func (t testSearchGroups) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, utils.GetSelfFuncName(), "operationID", t.OperationID, "errCode", errCode, "errMsg", errMsg)
}
func DoTestGetGroupsInfo() {
var test testGetGroupsInfo
groupIDList := []string{TestgroupID}
list := utils.StructToJsonString(groupIDList)
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DoTestGetGroupsInfo", "operationID", test.OperationID, "input", list)
// open_im_sdk.GetGroupsInfo(test, test.OperationID, list)
}
func DoTestSearchGroups() {
var test testGetGroupsInfo
var params sdk_params_callback.SearchGroupsParam
params.KeywordList = []string{"17"}
//params.IsSearchGroupID =true
params.IsSearchGroupName = true
open_im_sdk.SearchGroups(test, test.OperationID, utils.StructToJsonString(params))
}
type testJoinGroup struct {
OperationID string
}
func (t testJoinGroup) OnSuccess(data string) {
log.ZInfo(ctx, "testJoinGroup", "operationID", t.OperationID, "onSuccess", data)
}
func (t testJoinGroup) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "testJoinGroup", "operationID", t.OperationID, "onError", errCode, errMsg)
}
func DoTestJoinGroup() {
var test testJoinGroup
test.OperationID = utils.OperationIDGenerator()
groupID := "1003105543"
reqMsg := "121212"
ex := "ex"
log.ZInfo(ctx, "testJoinGroup", "operationID", test.OperationID, "input", groupID, reqMsg, ex)
open_im_sdk.JoinGroup(test, test.OperationID, groupID, reqMsg, constant.JoinBySearch, ex)
}
type testQuitGroup struct {
OperationID string
}
func (t testQuitGroup) OnSuccess(data string) {
log.ZInfo(ctx, "testQuitGroup", "operationID", t.OperationID, "onSuccess", data)
}
func (t testQuitGroup) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "testQuitGroup", "operationID", t.OperationID, "onError", errCode, errMsg)
}
func DoTestQuitGroup() {
var test testQuitGroup
test.OperationID = utils.OperationIDGenerator()
groupID := "19de93b442a1ca3b772aa0f12761939d"
log.ZInfo(ctx, "testQuitGroup", "operationID", test.OperationID, "input", groupID)
open_im_sdk.QuitGroup(test, test.OperationID, groupID)
}
type testGetJoinedGroupList struct {
OperationID string
}
/*
OnError(errCode int, errMsg string)
OnSuccess(data string)
*/
func (t testGetJoinedGroupList) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "testGetJoinedGroupList", "operationID", t.OperationID, "OnError", errCode, errMsg)
}
func (t testGetJoinedGroupList) OnSuccess(data string) {
log.ZInfo(ctx, "testGetJoinedGroupList", "operationID", t.OperationID, "OnSuccess", "output", data)
}
func DoTestGetJoinedGroupList() {
var test testGetJoinedGroupList
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.GetJoinedGroupList(test, test.OperationID)
}
type testGetGroupMemberList struct {
OperationID string
}
func (t testGetGroupMemberList) OnSuccess(data string) {
log.ZInfo(ctx, "testGetGroupMemberList", "operationID", t.OperationID, "function", utils.GetSelfFuncName(), "data", data)
}
func (t testGetGroupMemberList) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, "testGetGroupMemberList", "operationID", t.OperationID, "function", utils.GetSelfFuncName(), "errCode", errCode, "errMsg", errMsg)
}
func DotestGetGroupMemberList() {
var test testGetGroupMemberList
test.OperationID = utils.OperationIDGenerator()
var groupId = TestgroupID
open_im_sdk.GetGroupMemberList(test, test.OperationID, groupId, 4, 0, 100)
}
func DotestCos() {
//var callback baseCallback
//p := ws.NewPostApi(token, UserForSDK.ImConfig().ApiAddr)
//var storage common.ObjectStorage = common.NewCOS(p)
//test(storage, callback)
}
//funcation DotestMinio() {
// var callback baseCallback
// token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiIxMzkwMDAwMDAwMCIsIlBsYXRmb3JtIjoiSU9TIiwiZXhwIjoxNjQ1NzgyNDY0LCJuYmYiOjE2NDUxNzc2NjQsImlhdCI6MTY0NTE3NzY2NH0.T-SDoLxdlwRGOMZPIKriPtAlOGWCLodsGi1dWxN8kto"
// p := ws.NewPostApi(token, "https://storage.rentsoft.cn")
// minio := common.NewMinio(p)
// var storage common.ObjectStorage = minio
// log.NewInfo("", *minio)
// test(storage, callback)
//}
//
//funcation test(storage common.ObjectStorage, callback baseCallback) {
// dir, newName, err := storage.UploadFile("./cmd/main.go", funcation(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo("0", dir, newName, err)
// dir, newName, err = storage.UploadImage("C:\\Users\\Administrator\\Desktop\\1.jpg", funcation(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo("0", dir, newName, err, err)
// dir, newName, err = storage.UploadSound("./cmd/main.go", funcation(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo("0", dir, newName, err, err)
// snapshotURL, snapshotUUID, videoURL, videoUUID, err := storage.UploadVideo("./cmd/main.go", "C:\\Users\\Administrator\\Desktop\\1.jpg", funcation(progress int) {
// if progress == 100 {
// callback.OnSuccess("")
// }
// })
// log.NewInfo(snapshotURL, snapshotUUID, videoURL, videoUUID, err)
//}
type testGetGroupMembersInfo struct {
}
func (testGetGroupMembersInfo) OnError(errCode int32, errMsg string) {
fmt.Println("testGetGroupMembersInfo OnError", errCode, errMsg)
}
func (testGetGroupMembersInfo) OnSuccess(data string) {
fmt.Println("testGetGroupMembersInfo OnSuccess, output", data)
}
//
//funcation DotestGetGroupMembersInfo() {
// var test testGetGroupMembersInfo
// var memlist []string
// memlist = append(memlist, "307edc814bb0d04a")
// //memlist = append(memlist, "ded01dfe543700402608e19d4e2f839e")
// jlist, _ := json.Marshal(memlist)
// fmt.Println("GetGroupMembersInfo input : ", string(jlist))
// sdk_interface.GetGroupMembersInfo("7ff61d8f9d4a8a0d6d70a14e2683aad5", string(jlist), test)
// //GetGroupMemberList("05dc84b52829e82242a710ecf999c72c", 0, 0, test)
//}
//
type baseCallback struct {
OperationID string
callName string
}
func (t baseCallback) OnSuccess(data string) {
log.ZInfo(ctx, t.callName, "operationID", t.OperationID, "function", utils.GetSelfFuncName(), "data", data)
}
func (t baseCallback) OnError(errCode int32, errMsg string) {
log.ZInfo(ctx, t.callName, "operationID", t.OperationID, "function", utils.GetSelfFuncName(), "errCode", errCode, "errMsg", errMsg)
}
type testKickGroupMember struct {
baseCallback
}
type testGetGroupMemberListByJoinTimeFilter struct {
baseCallback
}
func DotestGetGroupMemberListByJoinTimeFilter() {
var test testGetGroupMemberListByJoinTimeFilter
test.OperationID = utils.OperationIDGenerator()
var memlist []string
jlist := utils.StructToJsonString(memlist)
log.ZInfo(ctx, "DotestGetGroupMemberListByJoinTimeFilter", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", jlist)
open_im_sdk.GetGroupMemberListByJoinTimeFilter(test, test.OperationID, "3750066757", 1, 40, 0, 0, jlist)
}
func DotestKickGroupMember() {
var test testKickGroupMember
test.OperationID = utils.OperationIDGenerator()
var memlist []string
memlist = append(memlist, MemberUserID)
jlist := utils.StructToJsonString(memlist)
log.ZInfo(ctx, "DotestKickGroupMember", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", jlist)
open_im_sdk.KickGroupMember(test, test.OperationID, TestgroupID, "kkk", jlist)
}
type testInviteUserToGroup struct {
baseCallback
}
func DotestInviteUserToGroup() {
var test testInviteUserToGroup
test.OperationID = utils.OperationIDGenerator()
var memlist []string
memlist = append(memlist, MemberUserID)
jlist := utils.StructToJsonString(memlist)
log.ZInfo(ctx, "DotestInviteUserToGroup", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", jlist)
open_im_sdk.InviteUserToGroup(test, test.OperationID, TestgroupID, "come", string(jlist))
}
type testGetGroupApplicationList struct {
baseCallback
}
func DotestGetRecvGroupApplicationList() string {
var test testGetGroupApplicationList
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DotestGetRecvGroupApplicationList", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", "")
// open_im_sdk.GetRecvGroupApplicationList(test, test.OperationID)
return ""
}
// funcation DoGroupApplicationList() {
// var test testGroupX
// fmt.Println("test DoGetGroupApplicationList....")
// sdk_interface.GetGroupApplicationList(test)
// }
type testTransferGroupOwner struct {
baseCallback
}
func DotestTransferGroupOwner() {
var test testTransferGroupOwner
test.OperationID = utils.OperationIDGenerator()
open_im_sdk.TransferGroupOwner(test, test.OperationID, TestgroupID, MemberUserID)
}
type testProcessGroupApplication struct {
baseCallback
}
func DoTestAcceptGroupApplication(uid string) {
var test testProcessGroupApplication
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DoTestAcceptGroupApplication", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", "")
open_im_sdk.AcceptGroupApplication(test, test.OperationID, TestgroupID, MemberUserID, "ok")
}
func DoTestGetUserReqGroupApplicationList() {
var test testProcessGroupApplication
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DoTestGetUserReqGroupApplicationList", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", "")
// open_im_sdk.GetSendGroupApplicationList(test, test.OperationID)
}
func DoTestGetRecvGroupApplicationList() {
var test testProcessGroupApplication
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DoTestGetRecvGroupApplicationList", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", "")
// open_im_sdk.GetRecvGroupApplicationList(test, test.OperationID)
}
func DotestRefuseGroupApplication(uid string) {
var test testProcessGroupApplication
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DotestRefuseGroupApplication", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", "")
open_im_sdk.RefuseGroupApplication(test, test.OperationID, TestgroupID, MemberUserID, "no")
}
type testSetGroupMemberNickname struct {
baseCallback
}
func DotestSetGroupMemberNickname(myUserID string) {
var test testSetGroupMemberNickname
test.OperationID = utils.OperationIDGenerator()
log.ZInfo(ctx, "DotestSetGroupMemberNickname", "operationID", test.OperationID, "function", utils.GetSelfFuncName(), "input", "")
open_im_sdk.SetGroupMemberNickname(test, test.OperationID, TestgroupID, myUserID, "")
}
func DoTestSetGroupMemberRoleLevel(groupID, userID string, roleLevel int) {
var test testSetGroupMemberNickname
test.OperationID = utils.OperationIDGenerator()
fmt.Println(test.OperationID, utils.GetSelfFuncName(), "inputx: ")
open_im_sdk.SetGroupMemberRoleLevel(test, test.OperationID, groupID, userID, roleLevel)
}
func DoTestSetGroupMemberInfo(groupID, userID string, ex string) {
var test testSetGroupMemberNickname
test.OperationID = utils.OperationIDGenerator()
param := sdk_params_callback.SetGroupMemberInfoParam{GroupID: groupID, UserID: userID}
if ex != "" {
param.Ex = &ex
}
g1 := utils.StructToJsonString(param)
fmt.Println(test.OperationID, utils.GetSelfFuncName(), "inputx: ", g1)
open_im_sdk.SetGroupMemberInfo(test, test.OperationID, g1)
}

View File

@@ -0,0 +1,160 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/tools/log"
"golang.org/x/net/context"
)
type testSignalingListener struct {
ctx context.Context
}
func (s *testSignalingListener) OnHangUp(hangUpCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnHangUp ", hangUpCallback)
}
func (s *testSignalingListener) OnReceiveNewInvitation(receiveNewInvitationCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnReceiveNewInvitation ", receiveNewInvitationCallback)
}
func (s *testSignalingListener) OnInviteeAccepted(inviteeAcceptedCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnInviteeAccepted ", inviteeAcceptedCallback)
}
func (s *testSignalingListener) OnInviteeRejected(inviteeRejectedCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnInviteeRejected ", inviteeRejectedCallback)
}
func (s *testSignalingListener) OnInvitationCancelled(invitationCancelledCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnInvitationCancelled ", invitationCancelledCallback)
}
func (s *testSignalingListener) OnInvitationTimeout(invitationTimeoutCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnInvitationTimeout ", invitationTimeoutCallback)
}
func (s *testSignalingListener) OnInviteeAcceptedByOtherDevice(inviteeAcceptedCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnInviteeAcceptedByOtherDevice ", inviteeAcceptedCallback)
}
func (s *testSignalingListener) OnInviteeRejectedByOtherDevice(inviteeRejectedCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "OnInviteeRejectedByOtherDevice ", inviteeRejectedCallback)
}
func (s *testSignalingListener) OnRoomParticipantConnected(onRoomChangeCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "onRoomChangeCallback", onRoomChangeCallback)
}
func (s *testSignalingListener) OnRoomParticipantDisconnected(onRoomChangeCallback string) {
log.ZInfo(s.ctx, utils.GetSelfFuncName(), "onRoomChangeCallback", onRoomChangeCallback)
}
//type testSingaling struct {
// baseCallback
//}
//
//funcation DoTestInviteInGroup() {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// req := &sdkws.SignalInviteInGroupReq{}
// req.Invitation = SetTestInviteInfo()
// s := utils.StructToJsonString(req)
// // log.Info(t.OperationID, utils.GetSelfFuncName(), "input: ", s)
// open_im_sdk.SignalingInviteInGroup(t, t.OperationID, s)
//}
//
//funcation SetTestInviteInfo() *sdkws.InvitationInfo {
// req := &sdkws.InvitationInfo{}
// req.Timeout = 1000
// req.InviteeUserIDList = []string{"3495023045"}
// req.MediaType = "video"
// req.RoomID = "1826384574"
// req.GroupID = "1826384574"
// req.SessionType = 2
// return req
//}
//
//funcation DoTestInvite(userID string) {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// req := &sdkws.SignalInviteReq{}
// req.OpUserID = userID
// req.Invitation = SetTestInviteInfo()
// req.Invitation.GroupID = ""
// req.Invitation.SessionType = 1
// req.Invitation.PlatformID = 1
// req.Invitation.Timeout = 30
// req.Invitation.MediaType = "video"
// req.Invitation.InviteeUserIDList = []string{"17726378428"}
// s := utils.StructToJsonString(req)
// fmt.Println(utils.GetSelfFuncName(), "input: ", s, t.OperationID)
// open_im_sdk.SignalingInvite(t, t.OperationID, s)
//}
//
//funcation DoTestAccept() {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// req := &sdkws.SignalAcceptReq{Invitation: &sdkws.InvitationInfo{}, OpUserID: "18349115126"}
// req.Invitation = SetTestInviteInfo()
// req.Invitation.InviterUserID = "18666662412"
// s := utils.StructToJsonString(req)
// // log.Info(t.OperationID, utils.GetSelfFuncName(), "input: ", s, req.String())
// open_im_sdk.SignalingAccept(t, t.OperationID, s)
//}
//
//funcation DoTestReject() {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// req := &sdkws.SignalRejectReq{Invitation: &sdkws.InvitationInfo{}, OpUserID: "18349115126"}
// req.Invitation = SetTestInviteInfo()
// req.Invitation.InviterUserID = "18666662412"
// s := utils.StructToJsonString(req)
// // log.Info(t.OperationID, utils.GetSelfFuncName(), "input: ", s)
// open_im_sdk.SignalingReject(t, t.OperationID, s)
//}
//
//funcation DoTestCancel() {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// req := &sdkws.SignalCancelReq{Invitation: &sdkws.InvitationInfo{}}
// req.Invitation = SetTestInviteInfo()
// req.Invitation.GroupID = ""
// req.Invitation.SessionType = 1
// req.Invitation.PlatformID = 1
// req.Invitation.Timeout = 10
// req.Invitation.InviterUserID = "18666662412"
// req.OpUserID = "18666662412"
// s := utils.StructToJsonString(req)
// // log.Info(t.OperationID, utils.GetSelfFuncName(), "input: ", s)
// open_im_sdk.SignalingCancel(t, t.OperationID, s)
//}
//
//funcation DoTestHungUp() {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// req := &sdkws.SignalHungUpReq{Invitation: &sdkws.InvitationInfo{}}
// req.Invitation = SetTestInviteInfo()
// s := utils.StructToJsonString(req)
// // log.Info(t.OperationID, utils.GetSelfFuncName(), "input: ", s)
// open_im_sdk.SignalingHungUp(t, t.OperationID, s)
//}
//
//funcation DoTestSignalGetRoomByGroupID(groupID string) {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// open_im_sdk.SignalingGetRoomByGroupID(t, t.OperationID, groupID)
//}
//
//funcation DoTestSignalGetTokenByRoomID(roomID string) {
// t := testSingaling{baseCallback{OperationID: utils.OperationIDGenerator(), callName: utils.GetSelfFuncName()}}
// open_im_sdk.SignalingGetTokenByRoomID(t, t.OperationID, roomID)
//}

View File

@@ -0,0 +1,177 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"encoding/json"
"errors"
"github.com/openimsdk/openim-sdk-core/v3/pkg/constant"
"github.com/openimsdk/openim-sdk-core/v3/pkg/network"
"github.com/openimsdk/openim-sdk-core/v3/pkg/server_api_params"
"github.com/openimsdk/openim-sdk-core/v3/pkg/utils"
"github.com/openimsdk/tools/log"
"sync"
"time"
"github.com/openimsdk/protocol/sdkws"
)
var (
INVITEUSERTOGROUP = ""
)
func InviteListToGroup(userIDList []string, groupID string) {
var inviteReq server_api_params.InviteUserToGroupReq
inviteReq.OperationID = utils.OperationIDGenerator()
inviteReq.GroupID = groupID
inviteReq.InvitedUserIDList = userIDList
for {
resp, err := network.Post2Api(INVITEUSERTOGROUP, inviteReq, AdminToken)
if err != nil {
log.ZWarn(ctx, "INVITE USER TO GROUP failed", err, "inviteReq", inviteReq)
continue
} else {
log.ZInfo(ctx, "InviteResponse", "operationID", inviteReq.OperationID, "response", string(resp))
return
}
}
}
func InviteToGroup(userID string, groupID string) {
var inviteReq server_api_params.InviteUserToGroupReq
inviteReq.OperationID = utils.OperationIDGenerator()
inviteReq.GroupID = groupID
inviteReq.InvitedUserIDList = []string{userID}
for {
resp, err := network.Post2Api(INVITEUSERTOGROUP, inviteReq, AdminToken)
if err != nil {
log.ZWarn(ctx, "INVITE USER TO GROUP failed", err, "inviteReq", inviteReq)
continue
} else {
log.ZInfo(ctx, "invite resp", "operationID", inviteReq.OperationID, "response", string(resp))
return
}
}
}
func CreateWorkGroup(number int) string {
t1 := time.Now()
RegisterWorkGroupAccounts(number)
log.ZInfo(ctx, "RegisterAccounts", "costTime", time.Since(t1), "onlineClientNumber", number)
groupID := ""
var req server_api_params.CreateGroupReq
//var memberList []*server_api_params.GroupAddMemberInfo
//for _, v := range allUserID {
// memberList = append(memberList, &server_api_params.GroupAddMemberInfo{UserID: v, RoleLevel: 1})
//}
// req.MemberList = memberList
req.OwnerUserID = "openIM123456"
for {
req.OperationID = utils.OperationIDGenerator()
req.GroupType = constant.WorkingGroup
req.OperationID = utils.OperationIDGenerator()
resp, err := network.Post2Api(CREATEGROUP, req, AdminToken)
if err != nil {
log.ZWarn(ctx, "CREATE GROUP failed", err, "resp", resp)
continue
} else {
type CreateGroupResp struct {
server_api_params.CommResp
GroupInfo sdkws.GroupInfo `json:"data"`
}
var result CreateGroupResp
err := json.Unmarshal(resp, &result)
if err != nil {
log.ZError(ctx, "Unmarshal failed", err, "resp", string(resp))
}
log.ZInfo(ctx, "Unmarshal", "operationID", req.OperationID, "response", string(resp), "result", result)
groupID = result.GroupInfo.GroupID
log.ZInfo(ctx, "create groupID", "operationID", req.OperationID, "groupID", groupID)
break
}
}
split := 100
idx := 0
remain := len(allUserID) % split
for idx = 0; idx < len(allUserID)/split; idx++ {
sub := allUserID[idx*split : (idx+1)*split]
log.ZWarn(ctx, "Invite to groupID", errors.New(""), "groupID", groupID)
InviteListToGroup(sub, groupID)
}
if remain > 0 {
sub := allUserID[idx*split:]
log.ZWarn(ctx, "Invite to groupID", errors.New(""), "operationID", req.OperationID, "groupID", groupID)
InviteListToGroup(sub, groupID)
}
//var wg sync.WaitGroup
//for _, v := range allUserID {
// wg.Add(1)
// go funcation(uID, gID string) {
// InviteToGroup(uID, gID)
// wg.Done()
// }(v, groupID)
//}
//wg.Wait()
return groupID
}
func RegisterWorkGroupAccounts(number int) {
var wg sync.WaitGroup
wg.Add(number)
for i := 0; i < number; i++ {
go func(t int) {
userID := GenUid(t, "workgroup")
register(userID)
log.ZInfo(ctx, "UserRegistered", "userID", userID)
wg.Done()
}(i)
}
wg.Wait()
log.ZInfo(ctx, "RegistrationFinished", "totalUsers", number)
}
func RegisterWorkGroupPressAccounts(number int) {
var wg sync.WaitGroup
wg.Add(number)
for i := 0; i < number; i++ {
go func(t int) {
userID := GenUid(t, "press_workgroup")
register(userID)
log.ZInfo(ctx, "UserRegistered", "userID", userID)
wg.Done()
}(i)
}
wg.Wait()
userID1 := GenUid(1234567, "workgroup")
register(userID1)
userID2 := GenUid(7654321, "workgroup")
register(userID2)
log.ZInfo(ctx, "RegistrationFinished", "totalUsers", number+2)
}

View File

@@ -0,0 +1,53 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test
import (
"fmt"
)
type WBase struct {
}
func (WBase) OnError(errCode int32, errMsg string) {
fmt.Println("get workmoments OnError", errCode, errMsg)
}
func (WBase) OnSuccess(data string) {
fmt.Println("get workmoments OnSuccess, ", data)
}
func (WBase) OnProgress(progress int) {
fmt.Println("OnProgress, ", progress)
}
//funcation TestGetWorkMomentsUnReadCount() {
// operationID := utils.OperationIDGenerator()
// var cb WBase
// open_im_sdk.GetWorkMomentsUnReadCount(cb, operationID)
//}
//
//funcation TestGetWorkMomentsNotification() {
// operationID := utils.OperationIDGenerator()
// var cb WBase
// offset := 0
// count := 10
// open_im_sdk.GetWorkMomentsNotification(cb, operationID, offset, count)
//}
//
//funcation TestClearWorkMomentsNotification() {
// operationID := utils.OperationIDGenerator()
// var cb WBase
// open_im_sdk.ClearWorkMomentsNotification(cb, operationID)
//}