connection.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package payload
  2. import "errors"
  3. /**
  4. * @Author linya.jj
  5. * @Date 2023/3/22 18:22
  6. */
  7. type SubscriptionModel struct {
  8. Type string `json:"type"`
  9. Topic string `json:"topic"`
  10. }
  11. // 长连接接入点请求
  12. type ConnectionEndpointRequest struct {
  13. ClientId string `json:"clientId"` //自建应用appKey; 三方应用suiteKey
  14. ClientSecret string `json:"clientSecret"` //自建应用appSecret; 三方应用suiteSecret
  15. Subscriptions []*SubscriptionModel `json:"subscriptions"`
  16. UserAgent string `json:"ua"`
  17. LocalIP string `json:"localIp"`
  18. Extras map[string]string `json:"extras"`
  19. }
  20. // 长连接接入点参数
  21. type ConnectionEndpointResponse struct {
  22. Endpoint string `json:"endpoint"`
  23. Ticket string `json:"ticket"`
  24. }
  25. func (r *ConnectionEndpointResponse) Valid() error {
  26. if r == nil {
  27. return errors.New("ConnectionEndpointResponseNil")
  28. }
  29. if r.Endpoint == "" || r.Ticket == "" {
  30. return errors.New("ConnectionEndpointResponseContentEmpty")
  31. }
  32. return nil
  33. }