From 5b9f30889df1b96a4563103b5ff57f287b0fcc84 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:37:53 +0800 Subject: [PATCH] fix: update open-im-sdk-core version. --- example/main.go | 4 ++-- example/module/MActor.go | 16 ++++++++-------- network/ws_server.go | 6 ++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/example/main.go b/example/main.go index 1222e25..f2036c1 100644 --- a/example/main.go +++ b/example/main.go @@ -57,9 +57,9 @@ func (gt *GateNet) CloseGate() { func main() { var sdkWsPort, logLevel *int var openIMWsAddress, openIMApiAddress, openIMDbDir *string - openIMApiAddress = flag.String("openIM_api_address", "http://14.29.213.197:50002", + openIMApiAddress = flag.String("openIM_api_address", "http://125.124.195.201:10002", "openIM api listening address") - openIMWsAddress = flag.String("openIM_ws_address", "ws://14.29.213.197:50001", + openIMWsAddress = flag.String("openIM_ws_address", "ws://125.124.195.201:10001", "openIM ws listening address") sdkWsPort = flag.Int("sdk_ws_port", 10003, "openIMSDK ws listening port") logLevel = flag.Int("openIM_log_level", 6, "control log output level") diff --git a/example/module/MActor.go b/example/module/MActor.go index d54dc38..e0fdd27 100644 --- a/example/module/MActor.go +++ b/example/module/MActor.go @@ -99,14 +99,14 @@ func (actor *MActorIm) run() { //} else { actor.sendEventResp(resp) // todo send msg //} - case <-actor.heartTicker.C: - if actor.heartFlag == true { - actor.heartFlag = false - } else { - log.Error("心跳包超时错误", "sessionId", actor.SessionId) - actor.isclosing = true - actor.a.Destroy() - } + //case <-actor.heartTicker.C: + // if actor.heartFlag == true { + // actor.heartFlag = false + // } else { + // log.Error("心跳包超时错误", "sessionId", actor.SessionId) + // actor.isclosing = true + // actor.a.Destroy() + // } } } } diff --git a/network/ws_server.go b/network/ws_server.go index 1577f4b..595399e 100644 --- a/network/ws_server.go +++ b/network/ws_server.go @@ -67,6 +67,12 @@ func (handler *WSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } conn.SetReadLimit(int64(handler.maxMsgLen)) + _ = conn.SetReadDeadline(time.Now().Add(30 * time.Second)) + conn.SetPongHandler(func(appData string) error { + conn.SetReadDeadline(time.Now().Add(30 * time.Second)) + log.Error("js自动心跳包") + return nil + }) handler.wg.Add(1) defer handler.wg.Done()