Documentation ¶
Index ¶
- type Clients
- func (c *Clients) OnClose(cli *client.Client)
- func (c *Clients) OnDataReport(cli *client.Client, msg *aiot.Protocol)
- func (c *Clients) OnDeviceControl(cli *client.Client, msg *aiot.Protocol)
- func (c *Clients) OnHeartBeat(cli *client.Client, msg *aiot.Protocol)
- func (c *Clients) OnRegister(cli *client.Client, msg *aiot.Protocol) bool
- func (c *Clients) OnRequest(cli *client.Client, msg *aiot.Protocol)
- func (c *Clients) OnResponse(cli *client.Client, msg *aiot.Protocol)
- type Server
- func (s *Server) Handler(clientConn net.Conn)
- func (s *Server) IsOnline(deviceId string) bool
- func (s *Server) Lock()
- func (s *Server) RegisterDevice(cli *client.Client, msg *aiot.Protocol)
- func (s *Server) Remove(deviceId string) bool
- func (s *Server) SetStatus(state State)
- func (s *Server) StartSrv()
- func (s *Server) SyncRequest(deviceId string, mstProto *aiot.MsgIdProto, req *aiot.BusinessReq, ...) error
- func (s *Server) UnLock()
- type ServerCallBack
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clients ¶
type Clients struct { }
实现client
func (*Clients) OnDataReport ¶
实现OnDataReport
func (*Clients) OnDeviceControl ¶
实现OnDeviceControl
func (*Clients) OnHeartBeat ¶
实现OnHeartBeat
func (*Clients) OnRegister ¶
实现OnRegister
type Server ¶
type Server struct { // 所有设备ID列表 key: masterId Devices map[string]*client.Client // logger Logger *zap.SugaredLogger // 守护进程间隔时间 RestartTime time.Duration // 定时器 Ticker *time.Ticker // contains filtered or unexported fields }
服务端结构体
var Srv *Server
全局服务
func NewServer ¶
func NewServer(addr string, serverId string, serverCallBack ServerCallBack, logger *zap.SugaredLogger, restartTime time.Duration) *Server
初始化服务
func (*Server) RegisterDevice ¶
处理设备注册
func (*Server) SyncRequest ¶
func (s *Server) SyncRequest(deviceId string, mstProto *aiot.MsgIdProto, req *aiot.BusinessReq, reply *aiot.BusinessReply) error
同步发送请求
type ServerCallBack ¶
type ServerCallBack interface { // 收到心跳 OnHeartBeat(c *client.Client, msg *aiot.Protocol) // 设备注册 OnRegister(c *client.Client, msg *aiot.Protocol) bool // 收到请求 OnRequest(c *client.Client, msg *aiot.Protocol) // 收到响应 OnResponse(c *client.Client, msg *aiot.Protocol) // 数据上报 OnDataReport(c *client.Client, msg *aiot.Protocol) // 设备控制 OnDeviceControl(c *client.Client, msg *aiot.Protocol) // 通道关闭 OnClose(c *client.Client) }
回调接口
Click to show internal directories.
Click to hide internal directories.