Esempio n. 1
0
        public void createGamblerServerInterface()
        {
            // create an instance of the service
            Service = new MyGamblerService(gambler);

            // start a JSON-RPC server; all methods tagged with the [JsonRpcMethod] attribute
            // will be invokable remotely; all requests as well as all responses will be
            // passed on to the interceptor; please note that the server will
            // automatically expose an additional method to control how requests will be
            // processed;
            // pass a simple interceptor, which simply prints all intercepted requests
            // and responses

            // This creates an Interceptor that has the two functions interceptRequest and interceptResponse
            //Follwoing the code for an Interceptor which simply prints all intercepted requests
            // and responses, just for illustration purposes
            Interceptor interceptor = new SampleInterceptor();
            gamblerSocketListener = null;
            try
            {
                // launch a socket listener accepting and handling JSON-RPC requests
                gamblerSocketListener = new SocketListener(gambler.PortNo, interceptor);
            }
            catch (IOException e)
            {

                Console.WriteLine(e.ToString());
            }
            if (gamblerSocketListener != null)
            {
                socketListeningThread = new Thread(new ThreadStart(gamblerSocketListener.start));
                socketListeningThread.IsBackground = true;
                socketListeningThread.Start();
            }
        }
Esempio n. 2
0
        public void destroyGamblerServerInterface()
        {
            try
            {
                //Destroy the service object
                Service = null;
                //Stop the socket listener
                gamblerSocketListener.stop();
            }
            catch
            {

            }
        }