/// <summary> /// End get additional extender configuration data (async) /// </summary> /// <param name="asyncResult"></param> /// <returns>Extender configuration data</returns> public ExtenderConfig EndGetExtenderConfig(IAsyncResult asyncResult) { if (_extendingServiceProtocol == null) { throw new KsiServiceException("Extending service protocol is missing from service."); } KsiServiceAsyncResult serviceAsyncResult = GetKsiServiceAsyncResult(asyncResult); if (!serviceAsyncResult.IsCompleted) { serviceAsyncResult.AsyncWaitHandle.WaitOne(); } byte[] data = _extendingServiceProtocol.EndGetExtenderConfig(serviceAsyncResult); PduPayload payload = ExtenderConfigRequestResponseParser.Parse(data); ExtenderConfigResponsePayload configResponsePayload = payload as ExtenderConfigResponsePayload; if (configResponsePayload == null) { Logger.Warn("Extender config request failed. Invalid response payload.{0}Payload:{0}{1}", Environment.NewLine, payload); throw new KsiServiceException("Invalid config response payload. Type: " + payload.Type); } return(new ExtenderConfig(configResponsePayload)); }
private void CheckExtenderConfigChange(Pdu pdu) { if (ExtenderConfigChanged != null) { ExtenderConfigResponsePayload configPayload = GetPayload(pdu, Constants.ExtenderConfigResponsePayload.TagType, null) as ExtenderConfigResponsePayload; if (configPayload != null) { ExtenderConfig extenderConfig = new ExtenderConfig(configPayload); if (_currentExtenderConfig == null || !_currentExtenderConfig.Equals(extenderConfig)) { _currentExtenderConfig = extenderConfig; ExtenderConfigChanged?.BeginInvoke(this, new ExtenderConfigChangedEventArgs(_currentExtenderConfig), EndExtenderConfigChanged, null); } } } }
/// <summary> /// Parse child tag /// </summary> protected override ITlvTag ParseChild(ITlvTag childTag) { switch (childTag.Type) { case Constants.ExtendResponsePayload.TagType: ExtendResponsePayload extendResponsePayload = childTag as ExtendResponsePayload ?? new ExtendResponsePayload(childTag); Payloads.Add(extendResponsePayload); return(extendResponsePayload); case Constants.ErrorPayload.TagType: return(ErrorPayload = childTag as ExtendErrorPayload ?? new ExtendErrorPayload(childTag)); case Constants.ExtenderConfigResponsePayload.TagType: ExtenderConfigResponsePayload configResponsePayload = childTag as ExtenderConfigResponsePayload ?? new ExtenderConfigResponsePayload(childTag); Payloads.Add(configResponsePayload); return(configResponsePayload); default: return(base.ParseChild(childTag)); } }
/// <summary> /// Create new extender configuration instance /// </summary> public ExtenderConfig(ExtenderConfigResponsePayload payload) : base(payload.ParentsUris) { MaxRequests = payload.MaxRequests; CalendarFirstTime = payload.CalendarFirstTime; CalendarLastTime = payload.CalendarLastTime; }