| | |
| | | // Client API for AiotService service |
| | | |
| | | type AiotService interface { |
| | | GetBusiness(ctx context.Context, in *BusinessReq, opts ...client.CallOption) (*BusinessReply, error) |
| | | // 发送指向单个设备的请求 |
| | | SendToNode(ctx context.Context, in *NodeReq, opts ...client.CallOption) (*BusinessReply, error) |
| | | // 直接发送tcp请求 |
| | | SendAiotReq(ctx context.Context, in *Protocol, opts ...client.CallOption) (*Protocol, 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 { |
| | |
| | | } |
| | | } |
| | | |
| | | func (c *aiotService) GetBusiness(ctx context.Context, in *BusinessReq, opts ...client.CallOption) (*BusinessReply, error) { |
| | | req := c.c.NewRequest(c.name, "AiotService.GetBusiness", in) |
| | | 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 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 { |
| | | GetBusiness(context.Context, *BusinessReq, *BusinessReply) error |
| | | // 发送指向单个设备的请求 |
| | | SendToNode(context.Context, *NodeReq, *BusinessReply) error |
| | | // 直接发送tcp请求 |
| | | SendAiotReq(context.Context, *Protocol, *Protocol) 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 { |
| | | GetBusiness(ctx context.Context, in *BusinessReq, out *BusinessReply) error |
| | | SendToNode(ctx context.Context, in *NodeReq, out *BusinessReply) error |
| | | SendAiotReq(ctx context.Context, in *Protocol, out *Protocol) error |
| | | SendToCluster(ctx context.Context, in *ClusterReq, out *BusinessReply) error |
| | | SendToNodes(ctx context.Context, in *NodesReq, out *BusinessReply) error |
| | | } |
| | | type AiotService struct { |
| | | aiotService |
| | |
| | | AiotServiceHandler |
| | | } |
| | | |
| | | func (h *aiotServiceHandler) GetBusiness(ctx context.Context, in *BusinessReq, out *BusinessReply) error { |
| | | return h.AiotServiceHandler.GetBusiness(ctx, in, out) |
| | | func (h *aiotServiceHandler) SendToNode(ctx context.Context, in *NodeReq, out *BusinessReply) error { |
| | | return h.AiotServiceHandler.SendToNode(ctx, in, out) |
| | | } |
| | | |
| | | func (h *aiotServiceHandler) SendAiotReq(ctx context.Context, in *Protocol, out *Protocol) error { |
| | | return h.AiotServiceHandler.SendAiotReq(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) |
| | | } |