From a0a5dc21bca5ffb029a1cc657d97b3497ef31739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B5=B7?= Date: Mon, 26 Aug 2024 09:51:13 +0800 Subject: [PATCH] =?UTF-8?q?perf=20=E8=B0=83=E6=95=B4rpc=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wcferry/client.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wcferry/client.go b/wcferry/client.go index 1353d86..8918681 100644 --- a/wcferry/client.go +++ b/wcferry/client.go @@ -21,7 +21,7 @@ type Client struct { MsgClient *MsgClient // 消息客户端 } -// 启动 wcf 服务 +// 注册消息服务 // return error 错误信息 func (c *Client) Connect() error { if c.ListenAddr == "" { @@ -30,21 +30,21 @@ func (c *Client) Connect() error { if c.ListenPort == 0 { c.ListenPort = 10086 } - // 注册 wcf 服务 + // 启动 rpc + if err := c.wxInitSDK(); err != nil { + return err + } + // 配置客户端 c.CmdClient = &CmdClient{ pbSocket: newPbSocket(c.ListenAddr, c.ListenPort), } c.MsgClient = &MsgClient{ pbSocket: newPbSocket(c.ListenAddr, c.ListenPort+1), } - // 启动 wcf 服务 - if err := c.wxInitSDK(); err != nil { - return err - } - // 自动注销 wcf + // 退出时注销 onquit.Register(func() { - c.CmdClient.Destroy() c.MsgClient.Destroy() + c.CmdClient.Destroy() c.wxDestroySDK() }) // 返回连接结果