saas-smartAi通信协议标准库
gongshangguo
2022-03-04 698ed86c7604c10b616ee9c2733ac57adb74185f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: aiot_business.proto
 
package aiot
 
import (
    fmt "fmt"
    proto "github.com/golang/protobuf/proto"
    math "math"
)
 
import (
    context "context"
    client "github.com/micro/go-micro/client"
    server "github.com/micro/go-micro/server"
)
 
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
 
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
 
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ client.Option
var _ server.Option
 
// Client API for AiotService service
 
type AiotService interface {
    // 发送指向单个设备的请求
    SendToNode(ctx context.Context, in *NodeReq, opts ...client.CallOption) (*BusinessReply, error)
    // 直接发送同步tcp请求
    SendAiotSyncReq(ctx context.Context, in *Protocol, opts ...client.CallOption) (*BusinessReply, error)
    // 直接发送异步tcp请求
    SendAiotAsyncReq(ctx context.Context, in *Protocol, opts ...client.CallOption) (*BusinessReply, error)
    // 发送群组请求
    SendToCluster(ctx context.Context, in *ClusterReq, opts ...client.CallOption) (*BusinessReply, error)
    // 向多个设备同时发起相同参数请求
    SendToNodes(ctx context.Context, in *NodesReq, opts ...client.CallOption) (*BusinessReply, error)
}
 
type aiotService struct {
    c    client.Client
    name string
}
 
func NewAiotService(name string, c client.Client) AiotService {
    if c == nil {
        c = client.NewClient()
    }
    if len(name) == 0 {
        name = "aiot"
    }
    return &aiotService{
        c:    c,
        name: name,
    }
}
 
func (c *aiotService) SendToNode(ctx context.Context, in *NodeReq, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendToNode", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
 
func (c *aiotService) SendAiotSyncReq(ctx context.Context, in *Protocol, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendAiotSyncReq", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
 
func (c *aiotService) SendAiotAsyncReq(ctx context.Context, in *Protocol, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendAiotAsyncReq", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
 
func (c *aiotService) SendToCluster(ctx context.Context, in *ClusterReq, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendToCluster", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
 
func (c *aiotService) SendToNodes(ctx context.Context, in *NodesReq, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendToNodes", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
 
// Server API for AiotService service
 
type AiotServiceHandler interface {
    // 发送指向单个设备的请求
    SendToNode(context.Context, *NodeReq, *BusinessReply) error
    // 直接发送同步tcp请求
    SendAiotSyncReq(context.Context, *Protocol, *BusinessReply) error
    // 直接发送异步tcp请求
    SendAiotAsyncReq(context.Context, *Protocol, *BusinessReply) error
    // 发送群组请求
    SendToCluster(context.Context, *ClusterReq, *BusinessReply) error
    // 向多个设备同时发起相同参数请求
    SendToNodes(context.Context, *NodesReq, *BusinessReply) error
}
 
func RegisterAiotServiceHandler(s server.Server, hdlr AiotServiceHandler, opts ...server.HandlerOption) error {
    type aiotService interface {
        SendToNode(ctx context.Context, in *NodeReq, out *BusinessReply) error
        SendAiotSyncReq(ctx context.Context, in *Protocol, out *BusinessReply) error
        SendAiotAsyncReq(ctx context.Context, in *Protocol, out *BusinessReply) error
        SendToCluster(ctx context.Context, in *ClusterReq, out *BusinessReply) error
        SendToNodes(ctx context.Context, in *NodesReq, out *BusinessReply) error
    }
    type AiotService struct {
        aiotService
    }
    h := &aiotServiceHandler{hdlr}
    return s.Handle(s.NewHandler(&AiotService{h}, opts...))
}
 
type aiotServiceHandler struct {
    AiotServiceHandler
}
 
func (h *aiotServiceHandler) SendToNode(ctx context.Context, in *NodeReq, out *BusinessReply) error {
    return h.AiotServiceHandler.SendToNode(ctx, in, out)
}
 
func (h *aiotServiceHandler) SendAiotSyncReq(ctx context.Context, in *Protocol, out *BusinessReply) error {
    return h.AiotServiceHandler.SendAiotSyncReq(ctx, in, out)
}
 
func (h *aiotServiceHandler) SendAiotAsyncReq(ctx context.Context, in *Protocol, out *BusinessReply) error {
    return h.AiotServiceHandler.SendAiotAsyncReq(ctx, in, out)
}
 
func (h *aiotServiceHandler) SendToCluster(ctx context.Context, in *ClusterReq, out *BusinessReply) error {
    return h.AiotServiceHandler.SendToCluster(ctx, in, out)
}
 
func (h *aiotServiceHandler) SendToNodes(ctx context.Context, in *NodesReq, out *BusinessReply) error {
    return h.AiotServiceHandler.SendToNodes(ctx, in, out)
}