public override Socket Accept()
        {
            Socket client = baseSocket.Accept();

            if (!client.IsConnected())
            {
                throw new IOException("Underlying socket connection failed.");
            }

            return(new GZipSocket(client, compressionLevel));
        }
        public override Socket Accept()
        {
            //Accept a client socket from the lower-level listener.
            RimSocket socket = new RimSocket(baseListener.Accept(), signatureAlgorithm, identityVerifier);

            //Authenticate the socket as a peer.
            socket.AuthenticatePeer();

            //Ensure the connection was successful; do not give a broken socket to the upper layer.
            if (!socket.IsConnected())
            {
                throw new Exception("Unknown problem authenticating client.");
            }

            //Return the connected socket.
            return(socket);
        }
Exemple #3
0
        public override Socket Accept()
        {
            //Accept a lower-level socket, and wrap it into an SslSocket instance for management.
            SslSocket socket = new SslSocket(baseListener.Accept(), authenticationListener);

            //Authenticate the remote endpoint with ourselves assuming the role of a server.
            socket.AuthenticateAsServer(serverCertificate);

            //Ensure the connection was successful; do not give a broken socket to the upper layer.
            if (!socket.IsConnected())
            {
                throw new Exception("Unknown problem authenticating client.");
            }

            //Return the connected socket.
            return(socket);
        }
Exemple #4
0
        public void AcceptConnection()
        {
            try
            {
                while (!Stopping.WaitOne(0))
                {
                    Socket handler = SocketListener.Accept();

                    lock (Connections)
                    {
                        Connections.Add(new BridgeConnection(handler));
                        Connections[Connections.Count - 1].Name = Connections.Count.ToString();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Exemple #5
0
        public void process()
        {
            //this.CalcularDevuelta(1670);

            inventory = new InventarioEfectivo();

            f56 = new F56(evnt, inventory);
            log.Debug("F56 Started");

            Thread.Sleep(1000);

            jcm = new JCMIvizion(evnt, inventory);
            jcm.StarCom();
            log.Debug("JCM Started");
            Thread.Sleep(1000);

            smrt = new SmartHopper(evnt, inventory);
            smrt.StartThread();
            log.Debug("smrt Started");
            Thread.Sleep(1000);



            //



            var _jcm   = jcm.getServiceStatus();
            var _f56   = f56.getServiceStatus();
            var _smart = smrt.getServiceStatus();

            evnt.GetEvent <Disable_Cash>().Publish(true);


            if (_jcm.error.HasError || _f56.error.HasError || _smart.error.HasError)
            {
                mach_status = machine_status.error;
            }
            if (_jcm.IsDone && _f56.IsDone)
            {
                mach_status = machine_status.idle;
            }
            log.Debug("Service started Started");
            using (var listener = new SocketListener(1337)) // Start listening
            {
                log.Debug("Socket Started");

                for (;;)
                {
                    try
                    {
                        using (var remote = listener.Accept()) // Accepts a connection (blocks execution)
                        {
                            var      data = remote.Receive();  // Receives data (blocks execution)
                            ComClass deserializedProduct = JsonConvert.DeserializeObject <ComClass>(data);


                            if (deserializedProduct.funciones == ComClass.function.cash_handling)
                            {
                                if (mach_status == machine_status.idle)
                                {
                                    HandlePaymentCash(deserializedProduct.Value);
                                    deserializedProduct.result = ComClass.status_cash.ok;
                                }
                                else
                                {
                                    deserializedProduct.result = ComClass.status_cash.fail;
                                }
                            }
                            else if (deserializedProduct.funciones == function.set_money)
                            {
                                this.SetMoney(deserializedProduct.Inventario, deserializedProduct.user);
                                deserializedProduct.result = status_cash.ok;
                            }
                            else if (deserializedProduct.funciones == function.add_money)
                            {
                                this.AddMoney(deserializedProduct.Inventario, deserializedProduct.user);
                                deserializedProduct.result = status_cash.ok;
                            }
                            else if (deserializedProduct.funciones == ComClass.function.system_status)
                            {
                                deserializedProduct.status = mach_status;
                            }
                            else if (deserializedProduct.funciones == function.get_devices_status)
                            {
                                deserializedProduct.DeviceStatus = new List <Common.ServiceStatus>();
                                deserializedProduct.DeviceStatus.Add(f56.getServiceStatus());
                                deserializedProduct.DeviceStatus.Add(smrt.getServiceStatus());
                                deserializedProduct.DeviceStatus.Add(jcm.getServiceStatus());
                            }
                            else if (deserializedProduct.funciones == ComClass.function.operation_status)
                            {
                                deserializedProduct.result = current_status;
                            }
                            else if (deserializedProduct.funciones == ComClass.function.get_money)
                            {
                                deserializedProduct.Inventario = inventory.GetInventario();
                            }
                            else if (deserializedProduct.funciones == ComClass.function.remove_money)
                            {
                                this.RemoveMoney(deserializedProduct.Inventario, deserializedProduct.user);
                                deserializedProduct.result = status_cash.ok;
                            }
                            remote.Send(JsonConvert.SerializeObject(deserializedProduct)); // Sends the received data back
                        }
                    }catch (SystemException E)
                    {
                        log.Error(E.Message);
                    }
                }
            }
        }
 public override Socket Accept()
 {
     return(new EncryptedSocket(baseListener.Accept(), keyExchangeAlgorithm));
 }