Ejemplo n.º 1
0
        /// <summary>
        /// Run the service stress op which stresses the bus attachment in a service type
        /// configuration by advertising a well known name which an implementation of the
        /// 'cat' method
        /// </summary>
        /// <param name="isMultipoint">True if operation uses multipoint sessions</param>
        private void RunService(bool isMultipoint)
        {
            try
            {
                ServiceBusListener serviceBusListener = new ServiceBusListener(this.busAtt, this);
                ServiceBusObject   serviceBusObject   = new ServiceBusObject(this.busAtt, this);
                this.DebugPrint("Registered the Service BusListener and BusObject");

                uint   flags           = (uint)(RequestNameType.DBUS_NAME_REPLACE_EXISTING | RequestNameType.DBUS_NAME_DO_NOT_QUEUE);
                string randServiceName = null;
                lock (rand)
                {
                    randServiceName = ServiceName + ".n" + rand.Next(10000000);
                }

                this.busAtt.RequestName(randServiceName, flags);

                SessionOpts optsIn = new SessionOpts(
                    TrafficType.TRAFFIC_MESSAGES,
                    isMultipoint,
                    ProximityType.PROXIMITY_ANY,
                    TransportMaskType.TRANSPORT_ANY);
                ushort[] portOut = new ushort[1];
                this.busAtt.BindSessionPort(ServicePort, portOut, optsIn, (SessionPortListener)serviceBusListener);

                this.busAtt.AdvertiseName(randServiceName, TransportMaskType.TRANSPORT_ANY);
                this.DebugPrint("Advertising WKN : " + randServiceName);

                int wait = 0;
                lock (rand)
                {
                    wait = 8000 + rand.Next(6000);
                }

                Task.Delay(wait).AsAsyncAction().AsTask().Wait();

                this.DebugPrint("Unraveling the service opertaion");
                this.busAtt.CancelAdvertiseName(randServiceName, TransportMaskType.TRANSPORT_ANY);
                this.busAtt.UnbindSessionPort(ServicePort);
                this.busAtt.ReleaseName(randServiceName);
                this.busAtt.UnregisterBusObject((BusObject)serviceBusObject);
                this.busAtt.UnregisterBusListener((BusListener)serviceBusListener);
                this.DebugPrint("Successfully unraveled the service opertaion");
            }
            catch (Exception ex)
            {
                var errMsg = AllJoynException.GetErrorMessage(ex.HResult);
                this.DebugPrint(">>>> Service Exectution Execution Error >>>> : " + errMsg);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Run the service stress op which stresses the bus attachment in a service type
        /// configuration by advertising a well known name which an implementation of the
        /// 'cat' method
        /// </summary>
        /// <param name="isMultipoint">True if operation uses multipoint sessions</param>
        private void RunService(bool isMultipoint)
        {
            try
            {
                ServiceBusListener serviceBusListener = new ServiceBusListener(this.busAtt, this);
                ServiceBusObject serviceBusObject = new ServiceBusObject(this.busAtt, this);
                this.DebugPrint("Registered the Service BusListener and BusObject");

                uint flags = (uint)(RequestNameType.DBUS_NAME_REPLACE_EXISTING | RequestNameType.DBUS_NAME_DO_NOT_QUEUE);
                string randServiceName = null;
                lock (rand)
                {
                    randServiceName = ServiceName + ".n" + rand.Next(10000000);
                }

                this.busAtt.RequestName(randServiceName, flags);

                SessionOpts optsIn = new SessionOpts(
                            TrafficType.TRAFFIC_MESSAGES,
                            isMultipoint,
                            ProximityType.PROXIMITY_ANY,
                            TransportMaskType.TRANSPORT_ANY);
                ushort[] portOut = new ushort[1];
                this.busAtt.BindSessionPort(ServicePort, portOut, optsIn, (SessionPortListener)serviceBusListener);

                this.busAtt.AdvertiseName(randServiceName, TransportMaskType.TRANSPORT_ANY);
                this.DebugPrint("Advertising WKN : " + randServiceName);

                int wait = 0;
                lock (rand)
                {
                    wait = 8000 + rand.Next(6000);
                }

                Task.Delay(wait).AsAsyncAction().AsTask().Wait();

                this.DebugPrint("Unraveling the service opertaion");
                this.busAtt.CancelAdvertiseName(randServiceName, TransportMaskType.TRANSPORT_ANY);
                this.busAtt.UnbindSessionPort(ServicePort);
                this.busAtt.ReleaseName(randServiceName);
                this.busAtt.UnregisterBusObject((BusObject)serviceBusObject);
                this.busAtt.UnregisterBusListener((BusListener)serviceBusListener);
                this.DebugPrint("Successfully unraveled the service opertaion");
            }
            catch (Exception ex)
            {
                var errMsg = AllJoynException.GetErrorMessage(ex.HResult);
                this.DebugPrint(">>>> Service Exectution Execution Error >>>> : " + errMsg);
            }
        }