using UPnP; using System; class MyService : UPnPService { public override void Action(string actionName, UPnPArgument[] inArgs, out UPnPArgument[] outArgs) { if (actionName == "MyAction") { // check if the required arguments exist in inArgs... if (inArgs.Length != 2) { ReportError(602, "Required arguments not provided", "/MyService/MyAction"); outArgs = null; return; } // perform the action... } } }
using UPnP; using System; class MyDevice : UPnPDevice { public override void CreateServices() { MyService myService = new MyService(); AddService(myService); } public override void OnSubscribe(UPnPService service) { // check if the requesting control point is authorized... if (!IsAuthorizedControlPoint(service.Subscriber)) { service.ReportError(602, "Access denied", "/MyDevice"); service.SubscriptionEnded(); } } }In this example, the ReportError method is called when a control point attempts to subscribe to a device but is not authorized. The error code 602 is passed along with a custom error message and the location of the error (in this case, the entire MyDevice object). The SubscriptionEnded method is also called to end the subscription process.