From 8fc1ade868feed86c2e0a4f48172bd305bbe8709 Mon Sep 17 00:00:00 2001 From: chenqinghe Date: Tue, 18 Oct 2022 15:11:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0OnSessionCreated?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client.go b/client.go index e07a2ba..4fc404d 100644 --- a/client.go +++ b/client.go @@ -21,6 +21,7 @@ type NewClientOptions struct { KeepalivePeriod time.Duration HeartbeatPacketFactory func() Packet OnConnected func(c Conn) error + OnSessionCreated func(s *Session) OnClosed func(session *Session) NeedReconnect bool ReconnectPolicy ReconnectPolicy @@ -40,6 +41,7 @@ func NewClient(codec Codec, handler Handler, opts *NewClientOptions) *Client { closed: make(chan struct{}), } cli.mgr = NewManager(handler, &NewManagerOptions{ + OnSessionCreated: opts.OnSessionCreated, AfterSessionClosed: func(s *Session) { cli.reconnect(s) },