public WoopsaSubscriptionService(WoopsaServer server, WoopsaContainer container)
: base(container, WoopsaSubscriptionServiceConst.WoopsaServiceSubscriptionName)
{
_server = server;
_subscriptionServiceImplementation = new WoopsaSubscriptionServiceImplementation(container, true);
_subscriptionServiceImplementation.BeforeWoopsaModelAccess +=
(sender, e) => { server.ExecuteBeforeWoopsaModelAccess(); };
_subscriptionServiceImplementation.AfterWoopsaModelAccess +=
(sender, e) => { server.ExecuteAfterWoopsaModelAccess(); };
MethodCreateSubscriptionChannel = new WoopsaMethod(
this,
WoopsaSubscriptionServiceConst.WoopsaCreateSubscriptionChannel,
WoopsaValueType.Integer,
new WoopsaMethodArgumentInfo[] { new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaNotificationQueueSize, WoopsaValueType.Integer) },
arguments => _subscriptionServiceImplementation.CreateSubscriptionChannel(arguments[0].ToInt32())
);
MethodRegisterSubscription = new WoopsaMethod(
this,
WoopsaSubscriptionServiceConst.WoopsaRegisterSubscription,
WoopsaValueType.Integer,
new WoopsaMethodArgumentInfo[] {
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionChannel, WoopsaValueType.Integer),
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaPropertyLink, WoopsaValueType.WoopsaLink),
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaMonitorInterval, WoopsaValueType.TimeSpan),
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaPublishInterval, WoopsaValueType.TimeSpan)
},
arguments =>
{
return _subscriptionServiceImplementation.RegisterSubscription(
arguments[0].ToInt32(), arguments[1].DecodeWoopsaLocalLink(),
arguments[2].ToTimeSpan(), arguments[3].ToTimeSpan());
});
MethodUnregisterSubscription = new WoopsaMethod(
this,
WoopsaSubscriptionServiceConst.WoopsaUnregisterSubscription,
WoopsaValueType.Logical,
new WoopsaMethodArgumentInfo[] {
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionChannel, WoopsaValueType.Integer),
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionId, WoopsaValueType.Integer)
},
arguments =>
{
return _subscriptionServiceImplementation.UnregisterSubscription(
arguments[0].ToInt32(), arguments[1].ToInt32());
});
MethodWaitNotification = new WoopsaMethod(
this,
WoopsaSubscriptionServiceConst.WoopsaWaitNotification,
WoopsaValueType.JsonData,
new WoopsaMethodArgumentInfo[] {
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionChannel, WoopsaValueType.Integer),
new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaLastNotificationId, WoopsaValueType.Integer)
},
arguments =>
{
using (var accessFreeSection = _server.EnterModelAccessFreeSection())
return new WoopsaValue(_subscriptionServiceImplementation.WaitNotification(
arguments[0].ToInt32(), arguments[1].ToInt32()));
});
}