123456789101112131415161718192021222324252627282930313233343536 |
- package public
- import (
- "context"
- "github.com/open-dingtalk/dingtalk-stream-sdk-go/client"
- "github.com/open-dingtalk/dingtalk-stream-sdk-go/event"
- "github.com/open-dingtalk/dingtalk-stream-sdk-go/logger"
- "github.com/open-dingtalk/dingtalk-stream-sdk-go/utils"
- )
- /**
- * @Author linya.jj
- * @Date 2023/3/22 18:30
- */
- func RunEventListener(clientId, clientSecret string) {
- logger.SetLogger(logger.NewStdTestLogger())
- eventHandler := event.NewDefaultEventFrameHandler(event.EventHandlerDoNothing)
- cli := client.NewStreamClient(
- client.WithAppCredential(client.NewAppCredentialConfig(clientId, clientSecret)),
- client.WithUserAgent(client.NewDingtalkGoSDKUserAgent()),
- client.WithSubscription(utils.SubscriptionTypeKEvent, "*", eventHandler.OnEventReceived),
- )
- err := cli.Start(context.Background())
- if err != nil {
- panic(err)
- }
- defer cli.Close()
- select {}
- }
|