package main

import (
	"github.com/zeromicro/go-zero/core/logx"
	"net/url"
	"wechat-api/internal/pkg/wechat_ws"
)

func msgHandler(msg wechat_ws.MsgJsonObject) error {
	logx.Info("当前处理的消息是：", msg)
	return nil
}

func main() {
	//u := url.URL{Scheme: "ws", Host: "chat.gkscrm.com:13088"}
	u := url.URL{Scheme: "ws", Host: "wecom.gkscrm.com:15088"}

	logx.Info(u.String())

	client, err := wechat_ws.NewWechatWsClient(u.String(), "default")
	if err != nil {
		return
	}

	go client.WritePump()

	client.SendMsg([]byte(`{
    "MsgType": "TalkToFriendTask",
    "Content": {
        "WxId": "1688856818598875",
        "ConvId": "7881302495311662",
        "ContentType": "Text",
        "Content": "5L2g5aW9",
        "TaskId": 17409293978671188
    }
}`))
	//
	//time.Sleep(5)
	//
	//client.SendMsg([]byte(`{"msgType":"text","message":"二次你好"}`))

	client.ReadPump(msgHandler)
}
