Skip to content

Commit

Permalink
test main
Browse files Browse the repository at this point in the history
skiffer-git committed Nov 3, 2021
1 parent f995d14 commit 838137e
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion open_im_sdk/init_login.go
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ func (u *UserRelated) login(uid, tk string, cb Base) {
}

func (u *UserRelated) timedCloseDB() {
timeTicker := time.NewTicker(time.Second * 30)
timeTicker := time.NewTicker(time.Second * 300)
for {
<-timeTicker.C
sdkLog("closeDBSetNil begin")
28 changes: 27 additions & 1 deletion test/main.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"math/rand"
"net"
"open_im_sdk/open_im_sdk"
"os"
"strconv"
@@ -223,7 +224,11 @@ func (z zx) txexfc(uid int) int {
func GenUid(uid int) string {
open_im_sdk.LogBegin(uid)

UidPrefix := "open_im_test_uid_"
if getMyIP() == "" {
fmt.Println("getMyIP() failed")
os.Exit(1)
}
UidPrefix := getMyIP() + "open_im_test_uid_"
open_im_sdk.LogSReturn(UidPrefix + strconv.FormatInt(int64(uid), 10))
return UidPrefix + strconv.FormatInt(int64(uid), 10)
}
@@ -285,6 +290,27 @@ func runGetToken(strMyUid string) string {

return token
}
func getMyIP() string {
addrs, err := net.InterfaceAddrs()

if err != nil {
fmt.Println(err)

os.Exit(1)
return ""
}
for _, address := range addrs {

if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
fmt.Println(ipnet.IP.String())
return ipnet.IP.String()
}

}
}
return ""
}

var (
APIADDR = ""

0 comments on commit 838137e

Please sign in to comment.