// Copyright 2019 getensh.com. All rights reserved. // Use of this source code is governed by getensh.com. package gate import ( "context" "encoding/json" "fmt" "git.getensh.com/common/gopkgs/logger" "go.uber.org/zap" "google.golang.org/grpc/status" pb_v1 "property-device/pb/v1" "property-device/timetask" "property-device/utils/gate_utils" ) // func GateOnline(ctx context.Context, req *pb_v1.GateOnlineRequest) (reply *pb_v1.GateOnlineReply, err error) { reply = &pb_v1.GateOnlineReply{} // 捕获各个task中的异常并返回给调用者 defer func() { if r := recover(); r != nil { err = fmt.Errorf("%+v", r) e := &status.Status{} if er := json.Unmarshal([]byte(err.Error()), e); er != nil { logger.Error("err", zap.String("system_err", err.Error()), zap.Stack("stacktrace")) } } }() timetask.UpdateGateTime(req.Sn, req.Protocol) if req.Protocol == gate_utils.GateProtocolYufanHttpV1 { reply.HasTask = gate_utils.HasCommand(req.Sn, req.Protocol) } return reply, nil }