未验证 提交 3c36d565 编写于 作者: 麦壳饼's avatar 麦壳饼 提交者: GitHub

Merge pull request #1008 from siaszhangjie/master

增加DeviceConnect、DeviceActivity订阅事件
......@@ -99,4 +99,34 @@ namespace IoTSharp.EventBus.Shashlik
await _subscriber.DeleteDevice(@event.DeviceId);
}
}
public class DeviceConnectEventHandler : IEventHandler<DeviceConnectEvent>
{
private readonly ISubscriber _subscriber;
public DeviceConnectEventHandler(ISubscriber subscriber)
{
_subscriber = subscriber;
}
public async Task Execute(DeviceConnectEvent @event, IDictionary<string, string> items)
{
var data = @event.Data;
if (data != null)
await _subscriber.Connect(data.DeviceId, data.ConnectStatus);
}
}
public class DeviceActivityEventHandler : IEventHandler<DeviceActivityEvent>
{
private readonly ISubscriber _subscriber;
public DeviceActivityEventHandler(ISubscriber subscriber)
{
_subscriber = subscriber;
}
public async Task Execute(DeviceActivityEvent @event, IDictionary<string, string> items)
{
var data = @event.Data;
if (data != null)
await _subscriber.Active(data.DeviceId, data.Activity);
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册