Provider for the openhome.org:SubscriptionLongPoll:1 UPnP service
Inheritance: DvProvider, IDisposable, IDvProviderOpenhomeOrgSubscriptionLongPoll1
        private static int DoSubscribe(IntPtr aPtr, IntPtr aInvocation)
        {
            GCHandle gch = GCHandle.FromIntPtr(aPtr);
            DvProviderOpenhomeOrgSubscriptionLongPoll1 self = (DvProviderOpenhomeOrgSubscriptionLongPoll1)gch.Target;
            DvInvocation invocation = new DvInvocation(aInvocation);
            string       clientId;
            string       udn;
            string       service;
            uint         requestedDuration;
            string       sid;
            uint         duration;

            try
            {
                invocation.ReadStart();
                clientId          = invocation.ReadString("ClientId");
                udn               = invocation.ReadString("Udn");
                service           = invocation.ReadString("Service");
                requestedDuration = invocation.ReadUint("RequestedDuration");
                invocation.ReadEnd();
                self.Subscribe(invocation, clientId, udn, service, requestedDuration, out sid, out duration);
            }
            catch (ActionError e)
            {
                invocation.ReportActionError(e, "Subscribe");
                return(-1);
            }
            catch (PropertyUpdateError)
            {
                invocation.ReportError(501, String.Format("Invalid value for property {0}", "Subscribe"));
                return(-1);
            }
            catch (Exception e)
            {
                Console.WriteLine("WARNING: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "Subscribe", e.TargetSite.Name);
                Console.WriteLine("         Only ActionError or PropertyUpdateError should be thrown by actions");
                return(-1);
            }
            try
            {
                invocation.WriteStart();
                invocation.WriteString("Sid", sid);
                invocation.WriteUint("Duration", duration);
                invocation.WriteEnd();
            }
            catch (ActionError)
            {
                return(-1);
            }
            catch (System.Exception e)
            {
                Console.WriteLine("ERROR: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "Subscribe", e.TargetSite.Name);
                Console.WriteLine("       Only ActionError can be thrown by action response writer");
            }
            return(0);
        }
Esempio n. 2
0
        private static int DoRenew(IntPtr aPtr, IntPtr aInvocation)
        {
            GCHandle gch = GCHandle.FromIntPtr(aPtr);
            DvProviderOpenhomeOrgSubscriptionLongPoll1 self = (DvProviderOpenhomeOrgSubscriptionLongPoll1)gch.Target;
            DvInvocation invocation = new DvInvocation(aInvocation);
            string       sid;
            uint         requestedDuration;
            uint         duration;

            try
            {
                invocation.ReadStart();
                sid = invocation.ReadString("Sid");
                requestedDuration = invocation.ReadUint("RequestedDuration");
                invocation.ReadEnd();
                self.Renew(invocation, sid, requestedDuration, out duration);
            }
            catch (ActionError e)
            {
                invocation.ReportActionError(e, "Renew");
                return(-1);
            }
            catch (PropertyUpdateError)
            {
                invocation.ReportError(501, String.Format("Invalid value for property {0}", new object[] { "Renew" }));
                return(-1);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("WARNING: unexpected exception {0} thrown by {1}", new object[] { e, "Renew" });
                System.Diagnostics.Debug.WriteLine("         Only ActionError or PropertyUpdateError should be thrown by actions");
                return(-1);
            }
            try
            {
                invocation.WriteStart();
                invocation.WriteUint("Duration", duration);
                invocation.WriteEnd();
            }
            catch (ActionError)
            {
                return(-1);
            }
            catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLine("WARNING: unexpected exception {0} thrown by {1}", new object[] { e, "Renew" });
                System.Diagnostics.Debug.WriteLine("       Only ActionError can be thrown by action response writer");
            }
            return(0);
        }
        private static int DoGetPropertyUpdates(IntPtr aPtr, IntPtr aInvocation)
        {
            GCHandle gch = GCHandle.FromIntPtr(aPtr);
            DvProviderOpenhomeOrgSubscriptionLongPoll1 self = (DvProviderOpenhomeOrgSubscriptionLongPoll1)gch.Target;
            DvInvocation invocation = new DvInvocation(aInvocation);
            string       clientId;
            string       updates;

            try
            {
                invocation.ReadStart();
                clientId = invocation.ReadString("ClientId");
                invocation.ReadEnd();
                self.GetPropertyUpdates(invocation, clientId, out updates);
            }
            catch (ActionError e)
            {
                invocation.ReportActionError(e, "GetPropertyUpdates");
                return(-1);
            }
            catch (PropertyUpdateError)
            {
                invocation.ReportError(501, String.Format("Invalid value for property {0}", "GetPropertyUpdates"));
                return(-1);
            }
            catch (Exception e)
            {
                Console.WriteLine("WARNING: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "GetPropertyUpdates", e.TargetSite.Name);
                Console.WriteLine("         Only ActionError or PropertyUpdateError should be thrown by actions");
                return(-1);
            }
            try
            {
                invocation.WriteStart();
                invocation.WriteString("Updates", updates);
                invocation.WriteEnd();
            }
            catch (ActionError)
            {
                return(-1);
            }
            catch (System.Exception e)
            {
                Console.WriteLine("ERROR: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "GetPropertyUpdates", e.TargetSite.Name);
                Console.WriteLine("       Only ActionError can be thrown by action response writer");
            }
            return(0);
        }