盒子状态变更推送
当服务器侦测到FBox发生状态变更,则会推送消息
消息内容为数组
单个对象属性如下表
| 字段名 | 类型 | 参数描述 |
|---|---|---|
| id | string | FBox的Id |
| state | int | 盒子当前状态,0:未知,1:已连接,2:超时,3:已断开 |
| net | int | 盒子网络类型1:网络 2:2G,3:3G(目前不支持)4:WIFI,5:4G |
| rssi | int | 信号:0~8 |
| vers | json对象 | FBox固件版本,fcs,fds,floader. |
| mode | int | FBox状态0:正常,1:透传中 |
侦听事件
/// <summary>
/// 启动
/// </summary>
public void Start()
{
// 通过参数登录服务器
_fbox.Restart().Wait();
//侦听盒子状态变更事件
_fbox.BoxConnectStateChanged += _fbox_BoxConnectStateChanged;
}
//在Program,Main函数中调用
class Program
{
static void Main(string[] args)
{
using (var fbox = new FBoxDemo())
{
fbox.Start(); //启动
fbox.StartAllDMonData();//开启FBox所有监控点
}
}
}
/// <summary>
/// 盒子状态变更函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void _fbox_BoxConnectStateChanged(object sender, IList<BoxConnectionStateItem> e)
{
foreach (var stateItem in e)
{
Console.WriteLine($"{stateItem.BoxNo},{stateItem.NewState}");
}
}