public IPhoneNSUrlProtocol(NSUrlRequest request, NSCachedUrlResponse cachedResponse, INSUrlProtocolClient client)
            : base(request, cachedResponse, client)
        {
            //SystemLogger.Log (SystemLogger.Module.PLATFORM, "# IPhoneNSUrlProtocol - Init with Request");

            serviceLocator = IPhoneServiceLocator.GetInstance ();
            serviceURIHandler = new IPhoneServiceURIHandler (serviceLocator);
            resourceURIHandler = new IPhoneResourceHandler (ApplicationSource.FILE);
            serviceInvocationManager = new ServiceInvocationManager ();
        }
        public IPhoneNSUrlProtocol(NSUrlRequest request, NSCachedUrlResponse cachedResponse, INSUrlProtocolClient client)
            : base(request, cachedResponse, client)
        {
            //SystemLogger.Log (SystemLogger.Module.PLATFORM, "# IPhoneNSUrlProtocol - Init with Request");

            serviceLocator           = IPhoneServiceLocator.GetInstance();
            serviceURIHandler        = new IPhoneServiceURIHandler(serviceLocator);
            resourceURIHandler       = new IPhoneResourceHandler(ApplicationSource.FILE);
            serviceInvocationManager = new ServiceInvocationManager();
        }
Beispiel #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        protected bool openSocketListener(NSDictionary settings)
        {
            bool socketOpened = false;

            try {

                int defaultIPCPort = AppDelegate.GetIPCDefaultPort (settings);
                #if DEBUG
                log ("Opening Listener on port " + defaultIPCPort + "...");
                #endif
                if (httpServer == null) {
                    httpServer = new HttpServer (new Server (defaultIPCPort));
                }
                socketOpened = true;

                #if DEBUG
                log ("Listener OPENED on port: " + httpServer.Server.Port);
                #endif
                // Adding Resource Handler.
                IPhoneResourceHandler resourceHandler = new IPhoneResourceHandler (ApplicationSource.FILE);
                //resourceHandler.Substitute = false;
                httpServer.Handlers.Add (resourceHandler);

                // Adding Service URI Handler.
                httpServer.Handlers.Add (new IPhoneServiceURIHandler (IPhoneServiceLocator.GetInstance ()));

                // Adding Remote Resource Handler.
                httpServer.Handlers.Add (new RemoteResourceHandler (IPhoneServiceLocator.GetInstance ()));

            } catch (Exception ex) {
                #if DEBUG
                log ("Cannot open internal server socket: " + ex.Message);
                #endif
            }

            return socketOpened;
        }
Beispiel #4
0
        /// <summary>
        /// Open Socket listener on specific port
        /// </summary>
        protected void openSocketListener(int port)
        {
            try {

                #if DEBUG
                log ("[2] Opening Listener on port " + port + "...");
                #endif
                if (httpServer == null) {
                    httpServer = new HttpServer (new Server (port));
                }
                socketOpened = true;

                #if DEBUG
                log ("[2] Listener OPENED on port: " + httpServer.Server.Port);
                #endif

                // Adding Resource Handler.
                IPhoneResourceHandler resourceHandler = new IPhoneResourceHandler (ApplicationSource.FILE);
                //resourceHandler.Substitute = false;
                httpServer.Handlers.Add (resourceHandler);
                httpServer.Handlers.Add (new RemoteResourceHandler (IPhoneServiceLocator.GetInstance ()));

            } catch (Exception ex) {
                #if DEBUG
                log ("[2] Cannot open internal server socket: " + ex.Message);
                #endif
                if(ex.GetType() == typeof(System.Net.Sockets.SocketException)) {
                    System.Net.Sockets.SocketException socketException = ex as System.Net.Sockets.SocketException;
                    //log ("[2] Socket exception: " + socketException.SocketErrorCode);
                    if (socketException.SocketErrorCode == System.Net.Sockets.SocketError.AddressAlreadyInUse) {
                        #if DEBUG
                        log ("[2] Address already in use; trying with next port...");
                        #endif
                        this.openSocketListener (port + 1);
                    }
                }
            }
        }