public CloverTransport getCloverTransport()
 {
     if (transport == null)
     {
         transport = new USBCloverTransport(this.deviceId, pingSleepSeconds);
     }
     return(transport);
 }
Exemplo n.º 2
0
 public CloverTransport getCloverTransport()
 {
     if (transport == null)
     {
         transport = new WebSocketCloverTransport(endpoint, this, this, posName, serialNumber, pairingAuthToken);
     }
     return(transport);
 }
        public void onDeviceReady(CloverTransport device)
        {
            //CloverTransportObserver]

            foreach (CloverTransportObserver devOvs in deviceObservers)
            {
                devOvs.onDeviceReady(transport);
            }
        }
 public CloverDevice(string packageName, CloverTransport transport, string remoteApplicationID)
 {
     this.transport   = transport;
     this.packageName = packageName;
     System.Reflection.Assembly assembly = System.Reflection.Assembly.Load("CloverConnector");
     this.remoteSourceSDK = AssemblyUtils.GetAssemblyAttribute <System.Reflection.AssemblyDescriptionAttribute>(assembly).Description + ":"
                            + (AssemblyUtils.GetAssemblyAttribute <System.Reflection.AssemblyFileVersionAttribute>(assembly)).Version
                            + (AssemblyUtils.GetAssemblyAttribute <System.Reflection.AssemblyInformationalVersionAttribute>(assembly)).InformationalVersion;
     this.deviceInfo          = new DeviceInfo();
     this.remoteApplicationID = remoteApplicationID;
 }
Exemplo n.º 5
0
 public CloverTransport getCloverTransport()
 {
     if (transport == null)
     {
         if (useLegacyUsbTransport)
         {
             transport = new USBCloverTransport(this.deviceId, pingSleepSeconds);
         }
         else
         {
             transport = new usb.UsbCloverTransport();
         }
     }
     return(transport);
 }
Exemplo n.º 6
0
 public void onDeviceReady(CloverTransport device)
 {
     string message = "{" +
         "\"id\":\"208\"," +
         "\"method\":\"DISCOVERY_REQUEST\"," +
         "\"packageName\":\"com.clover.remote.protocol.usb\"," +
         "\"payload\":\"{\\\"method\\\":\\\"DISCOVERY_REQUEST\\\",\\\"version\\\":1}\"," +
         "\"type\":\"COMMAND\"" +
         "}";
     ConsoleKeyInfo info;
     do
     {
         device.sendMessage(message);
         // Wait for user input..
         info = Console.ReadKey();
     } while (info.KeyChar != 'x');
 }
 /// <summary>
 /// Add observer listener to this transport
 /// </summary>
 /// <param name="observer"></param>
 public void Subscribe(CloverTransportObserver observer)
 {
     if (observer != null && !observers.Contains(observer))
     {
         CloverTransport me = this;
         if (ready)
         {
             BackgroundWorker bw = new BackgroundWorker();
             // what to do in the background thread
             bw.DoWork += delegate
             {
                 observer.onDeviceReady(me);
             };
             bw.RunWorkerAsync();
         }
         observers.Add(observer);
     }
 }
Exemplo n.º 8
0
        public void onDeviceReady(CloverTransport device)
        {
            string message = "{" +
                             "\"id\":\"208\"," +
                             "\"method\":\"DISCOVERY_REQUEST\"," +
                             "\"packageName\":\"com.clover.remote.protocol.usb\"," +
                             "\"payload\":\"{\\\"method\\\":\\\"DISCOVERY_REQUEST\\\",\\\"version\\\":1}\"," +
                             "\"type\":\"COMMAND\"" +
                             "}";
            ConsoleKeyInfo info;

            do
            {
                device.sendMessage(message);
                // Wait for user input..
                info = Console.ReadKey();
            } while (info.KeyChar != 'x');
        }
        public void Subscribe(CloverTransportObserver observer)
        {
            CloverTransport me = this;

            if (ready)
            {
                BackgroundWorker bw = new BackgroundWorker();
                // what to do in the background thread
                bw.DoWork += new DoWorkEventHandler(
                    delegate(object o, DoWorkEventArgs args)
                {
                    BackgroundWorker b = o as BackgroundWorker;
                    observer.onDeviceReady(me);
                });
                bw.RunWorkerAsync();
            }
            observers.Add(observer);
        }
        public void onDeviceReady(CloverTransport transport)
        {
            bool stop = false;
            ConsoleKeyInfo info;
            do
            {
                // Wait for user input..
                info = Console.ReadKey();

                switch (info.KeyChar)
                {
                    case 'x': stop = true; break;
                    case '1': device.doDiscoveryRequest(); break;
                    case '2': device.doShowThankYouScreen(); break;
                    case '3': device.doShowWelcomeScreen(); break;
                    case '4': device.doTerminalMessage("Holy jumping weasel critters on a hot cross bun!"); break;
                }
            } while (!stop);
        }
        internal static string getRemoteSdk(this CloverDeviceConfiguration config, CloverTransport transport)
        {
            string REG_KEY  = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\CloverSDK";
            string receiver = "DLL";

            try
            {
                object rReceiver = Registry.GetValue(REG_KEY, "DisplayName", "unset");
                if (rReceiver != null && !rReceiver.ToString().Equals("unset"))
                {
                    receiver = rReceiver.ToString();
                }
            }
            catch (Exception e)
            {
                using (EventLog eventLog = new EventLog("Application"))
                {
                    eventLog.Source = "Application";
                    eventLog.WriteEntry($"{config.getMessagePackageName().GetType()}->{e.Message}");
                }
            }

            string shortTitle         = transport.ShortTitle();
            string shortTransportType = String.IsNullOrWhiteSpace(shortTitle) ? "UNKNOWN" : shortTitle;

            // Build SdkInfo string
            System.Reflection.Assembly assembly = System.Reflection.Assembly.Load("CloverConnector");
            string sdkInfoString = AssemblyUtils.GetAssemblyAttribute <System.Reflection.AssemblyDescriptionAttribute>(assembly).Description
                                   + "_" + receiver
                                   + "|" + shortTransportType
                                   + ":"
                                   + (assembly.GetAssemblyAttribute <System.Reflection.AssemblyFileVersionAttribute>()).Version
                                   + (assembly.GetAssemblyAttribute <System.Reflection.AssemblyInformationalVersionAttribute>()).InformationalVersion;

            using (EventLog eventLog = new EventLog("Application"))
            {
                eventLog.Source = "Application";
                eventLog.WriteEntry($"{config.getMessagePackageName().GetType()}->SDKInfo from assembly and registry = {sdkInfoString}");
            }

            return(sdkInfoString);
        }
Exemplo n.º 12
0
        public void onDeviceReady(CloverTransport transport)
        {
            bool stop = false;

            do
            {
                // Wait for user input..
                switch (Console.ReadKey().KeyChar)
                {
                case 'x': stop = true; break;

                case '1': device.doDiscoveryRequest(); break;

                case '2': device.doShowThankYouScreen(); break;

                case '3': device.doShowWelcomeScreen(); break;

                case '4': device.doTerminalMessage("Holy jumping weasel critters on a hot cross bun!"); break;
                }
            } while (!stop);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initialize the Clover Device for use
        /// </summary>
        /// <param name="configuration"></param>
        public virtual void Initialize(CloverDeviceConfiguration configuration)
        {
            string logSource = "_TransportEventLog";

            if (!EventLog.SourceExists(logSource))
            {
                EventLog.CreateEventSource(logSource, logSource);
            }

            // Add the event log trace listener to the collection.
            EventLogTraceListener myTraceListener = new EventLogTraceListener(logSource);

            Trace.Listeners.Add(myTraceListener);

            transport = configuration.getCloverTransport();

            shortTransportType = !string.IsNullOrWhiteSpace(transport.ShortTitle()) ? transport.ShortTitle() : shortTransportType;
            packageName        = configuration.getMessagePackageName();
            remoteSourceSDK    = getSDKInfoString();
            deviceInfo         = new DeviceInfo();
        }
        /// <summary>
        /// Initialize the Clover Device for use
        /// </summary>
        /// <param name="configuration"></param>
        public virtual void Initialize(CloverDeviceConfiguration configuration)
        {
            string logSource = "_TransportEventLog";

            try
            {
                // If this EventLog code crashes, you don't have the Windows Event Log Source setup, and this code isn't running with sufficient credentials to create it.
                // See https://github.com/clover/remote-pay-windows/wiki/ "Setting up the Windows Event Log" article for details.
                //
                // Quickfixs: run this app _once_ as admin so this code can perform setup, or just run this in an admin PowerShell> New-EventLog -LogName "Application" -Source "_TransportEventLog"
                //            Other fixes available in the project's wiki article.
                //
                // When this app is deployed into production, the installer or deploy script should ensure the EventLog is created.

                if (!EventLog.SourceExists(logSource))
                {
                    EventLog.CreateEventSource(logSource, logSource);
                }

                // Add the event log trace listener to the collection.
                EventLogTraceListener eventlog = new EventLogTraceListener(logSource);
                Trace.Listeners.Add(eventlog);
            }
            catch (Exception exception)
            {
                // If this has crashed, see the comment just above at the top of the EventLog try for details and quick fixes.
                throw new CloverException($"Aborting Clover Connector SDK because the Windows Event Log Source \"{logSource}\" does not exist or cannot be accessed.\nSee the https://github.com/clover/remote-pay-windows/wiki article for more information.\n\nref# CLOVER-W230\nDetail Message: {exception.Message}", "CLOVER-W230", exception);
            }

            Log(MessageLevel.Detailed, $"CloverDevice.{nameof(Initialize)} {configuration.getName()}, raid: {configuration.getRemoteApplicationID()}");

            transport = configuration.getCloverTransport();
            transport?.SetLogLevel(logLevel);

            shortTransportType = !string.IsNullOrWhiteSpace(transport.ShortTitle()) ? transport.ShortTitle() : shortTransportType;
            packageName        = configuration.getMessagePackageName();
            remoteSourceSDK    = getSDKInfoString();
            deviceInfo         = new DeviceInfo();
        }
 public void onDeviceDisconnected(CloverTransport transport)
 {
     deviceObservers.ForEach(x => x.onDeviceDisconnected());
 }
 public void onDeviceDisconnected(CloverTransport transport)
 {
     Console.WriteLine("Device disconnect.");
 }
Exemplo n.º 17
0
        public void onDeviceReady(CloverTransport device)
        {
            //CloverTransportObserver]

            foreach (CloverTransportObserver devOvs in deviceObservers)
            {
                devOvs.onDeviceReady(transport);
            }
        }
Exemplo n.º 18
0
 public void onDeviceDisconnected(CloverTransport transport)
 {
     //CloverTransportObserver
 }
 public DefaultCloverDevice(String packageName, CloverTransport transport, String remoteApplicationID)
     : base(packageName, transport, remoteApplicationID)
 {
     transport.Subscribe(this);
 }
Exemplo n.º 20
0
 public void onDeviceConnected(CloverTransport transport)
 {
     Console.WriteLine("Device found.");
 }
 public void onDeviceDisconnected(CloverTransport transport)
 {
     deviceObservers.ForEach(x => x.onDeviceDisconnected());
 }
Exemplo n.º 22
0
 public void onDeviceDisconnected(CloverTransport device)
 {
     Console.WriteLine("Device disconnect.");
 }
 public void onDeviceReady(CloverTransport device)
 {
     doDiscoveryRequest();
 }
Exemplo n.º 24
0
 public USBCloverTransportListener(CloverTransport device)
 {
     this.device = device;
 }
Exemplo n.º 25
0
 public void onDeviceReady(CloverTransport device)
 {
     startupConnectionState = ConnectionState.Discovering;
     doDiscoveryRequest();
 }
 public DefaultCloverDevice(String packageName, CloverTransport transport, String remoteApplicationID) : base(packageName, transport, remoteApplicationID)
 {
     transport.Subscribe(this);
 }
 public void onDeviceConnected(CloverTransport transport)
 {
     Console.WriteLine("Device Connected");
 }
Exemplo n.º 28
0
 public USBCloverTransportListener(CloverTransport device)
 {
     this.device = device;
 }
 public void onDeviceReady(CloverTransport device)
 {
     doDiscoveryRequest();
 }
 public void onDeviceDisconnected(CloverTransport transport)
 {
     //CloverTransportObserver
 }
Exemplo n.º 31
0
        public void onDeviceDisconnected(CloverTransport transport)
        {
            startupConnectionState = ConnectionState.Disconnected;

            NotifyObservers(observer => observer.onDeviceDisconnected());
        }
Exemplo n.º 32
0
 public CloverDevice(string packageName, CloverTransport transport, string remoteApplicationID)
 {
     this.transport = transport;
     this.packageName = packageName;
     System.Reflection.Assembly assembly = System.Reflection.Assembly.Load("CloverConnector");
     this.remoteSourceSDK = AssemblyUtils.GetAssemblyAttribute<System.Reflection.AssemblyDescriptionAttribute>(assembly).Description + ":"
         + (AssemblyUtils.GetAssemblyAttribute<System.Reflection.AssemblyFileVersionAttribute>(assembly)).Version
         + (AssemblyUtils.GetAssemblyAttribute<System.Reflection.AssemblyInformationalVersionAttribute>(assembly)).InformationalVersion;
     this.deviceInfo = new DeviceInfo();
     this.remoteApplicationID = remoteApplicationID;
 }