示例#1
0
        public virtual void OnPrintJobStatusRequest(PrintJobStatusRequest request)
        {
            OnPrintJobStatusRequestMessage msg = new OnPrintJobStatusRequestMessage();

            msg.payload = request;
            WebSocket.Send(Serialize(msg));
        }
示例#2
0
 public void RetrievePrintJobStatus(PrintJobStatusRequest request)
 {
     if (websocket != null)
     {
         RetrievePrintJobStatusRequestMessage msg = new RetrievePrintJobStatusRequestMessage();
         msg.payload = request;
         websocket.Send(JsonUtils.Serialize(msg));
     }
 }
示例#3
0
 public void PrintJobStatus(HttpListenerContext context)
 {
     try
     {
         PrintJobStatusRequest message = ParseRequest <PrintJobStatusRequest>(context);
         GetServer.CloverConnector.RetrievePrintJobStatus(message);
         this.SendTextResponse(context, "");
     }
     catch (Exception e)
     {
         context.Response.StatusCode        = 400;
         context.Response.StatusDescription = e.Message;
         this.SendTextResponse(context, "error processing request");
     }
 }
示例#4
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            string logSource = "_TransportEventLog";

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

            EventLogTraceListener myTraceListener = new EventLogTraceListener(logSource);

            // Add the event log trace listener to the collection.
            Trace.Listeners.Add(myTraceListener);

            if (args.Length == 0)
            {
                // Retrieve the arguments from the service ImagePath
                args = Environment.GetCommandLineArgs();
            }

            if (args.Length > 0)
            {
                if (((ICollection <string>)args).Contains("-debug"))
                {
                    Debug = true;
                }

                if (((ICollection <string>)args).Any(a => a.Contains("-timer")))
                {
                    IEnumerable <string> timerStrings = ((ICollection <string>)args).Where(a => a.Contains("-timer"));
                    if (timerStrings.Count() == 1)
                    {
                        try
                        {
                            string timerString  = timerStrings.First();
                            int    index        = timerString.IndexOf('=');
                            string timerSeconds = timerString.Substring(index + 1);
                            Timer = Convert.ToInt32(timerSeconds);
                        }
                        catch
                        {
                            Timer = 1;
                            EventLog.WriteEntry(SERVICE_NAME, "Error parsing the -timer command line argument.  Setting timer to 1 second.");
                        }
                    }
                }
            }

            //load args in to dictionary
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if ("/T".Equals(args[i]))
                    {
                        parameters.Add("/T", "true");
                    }
                    else if (i + 1 < args.Length)
                    {
                        parameters.Add(args[i], args[++i]);
                    }
                }
            }

            IWebSocketConnection          sendSocket   = null;
            Action <IWebSocketConnection> serverSocket = socket =>
            {
                socket.OnOpen = () =>
                {
                    Console.WriteLine("Open! " + clientConnections.Count);
                    if (clientConnections.Count > 0)
                    {
                        if (clientConnections[0].IsAvailable)
                        {
                            socket.Close();
                            connectorListener.OnDeviceError(new CloverDeviceErrorEvent(CloverDeviceErrorEvent.CloverDeviceErrorType.EXCEPTION, 0, null, "Another client is already connected"));
                            return;
                        }
                    }
                    sendSocket = socket;
                    clientConnections.Add(socket);

                    connectorListener.WebSocket = sendSocket;
                    connectorListener.SendConnectionStatus();
                };
                socket.OnClose = () =>
                {
                    clientConnections.Remove(socket);
                    Console.WriteLine("Close!");
                    connectorListener.WebSocket = null;
                };
                socket.OnMessage = message =>
                {
                    try
                    {
                        JObject         jsonObj = (JObject)JsonConvert.DeserializeObject(message);
                        JToken          method  = jsonObj.GetValue(ServicePayloadConstants.PROP_METHOD);
                        JObject         payload = (JObject)jsonObj.GetValue(ServicePayloadConstants.PROP_PAYLOAD);
                        WebSocketMethod wsm     = (WebSocketMethod)Enum.Parse(typeof(WebSocketMethod), method.ToString());

                        switch (wsm)
                        {
                        case WebSocketMethod.Status:
                        {
                            connectorListener.SendConnectionStatus();
                            break;
                        }

                        case WebSocketMethod.OpenCashDrawer:
                        {
                            OpenCashDrawerRequest request = JsonUtils.Deserialize <OpenCashDrawerRequest>(payload.ToString());
                            cloverConnector.OpenCashDrawer(request);
                            break;
                        }

                        case WebSocketMethod.ShowMessage:
                        {
                            string msg = ((JObject)payload).GetValue("Message").Value <string>();
                            cloverConnector.ShowMessage(msg);
                            break;
                        }

                        case WebSocketMethod.ShowThankYouScreen:
                        {
                            cloverConnector.ShowThankYouScreen();
                            break;
                        }

                        case WebSocketMethod.ShowWelcomeScreen:
                        {
                            cloverConnector.ShowWelcomeScreen();
                            break;
                        }

                        case WebSocketMethod.Break:     // deprecated. use ResetDevice
                        case WebSocketMethod.ResetDevice:
                        {
                            cloverConnector.ResetDevice();
                            break;
                        }

                        case WebSocketMethod.PrintText:
                        {
                            JArray        messages    = (JArray)payload.GetValue("Messages");
                            List <string> messageList = new List <string>();
                            foreach (string msg in messages)
                            {
                                messageList.Add(msg);
                            }
                            cloverConnector.Print(new PrintRequest()
                                {
                                    text = messageList
                                });
                            break;
                        }

                        case WebSocketMethod.PrintImage:
                        {
                            string       base64Img = ((JObject)payload).GetValue("Bitmap").Value <string>();
                            byte[]       imgBytes  = Convert.FromBase64String(base64Img);
                            MemoryStream ms        = new MemoryStream();
                            ms.Write(imgBytes, 0, imgBytes.Length);
                            Bitmap bp = new Bitmap(ms);
                            ms.Close();
                            cloverConnector.Print(new PrintRequest()
                                {
                                    images = new List <Bitmap> {
                                        bp
                                    }
                                });
                            break;
                        }

                        case WebSocketMethod.PrintImageFromURL:
                        {
                            string url = ((JObject)payload).GetValue("Url").Value <string>();
                            cloverConnector.Print(new PrintRequest()
                                {
                                    imageURLs = new List <string> {
                                        url
                                    }
                                });
                            break;
                        }

                        case WebSocketMethod.Auth:
                        {
                            AuthRequest authRequest = JsonUtils.Deserialize <AuthRequest>(payload.ToString());
                            cloverConnector.Auth(authRequest);
                            break;
                        }

                        case WebSocketMethod.PreAuth:
                        {
                            PreAuthRequest preAuthRequest = JsonUtils.Deserialize <PreAuthRequest>(payload.ToString());
                            cloverConnector.PreAuth(preAuthRequest);
                            break;
                        }

                        case WebSocketMethod.TipAdjustAuth:
                        {
                            TipAdjustAuthRequest tipAdjustRequest = JsonUtils.Deserialize <TipAdjustAuthRequest>(payload.ToString());
                            cloverConnector.TipAdjustAuth(tipAdjustRequest);
                            break;
                        }

                        case WebSocketMethod.CapturePreAuth:
                        {
                            CapturePreAuthRequest capturePreAuthRequest = JsonUtils.Deserialize <CapturePreAuthRequest>(payload.ToString());
                            cloverConnector.CapturePreAuth(capturePreAuthRequest);
                            break;
                        }

                        case WebSocketMethod.Sale:
                        {
                            SaleRequest saleRequest = JsonUtils.Deserialize <SaleRequest>(payload.ToString());
                            cloverConnector.Sale(saleRequest);
                            break;
                        }

                        case WebSocketMethod.InvokeInputOption:
                        {
                            InputOption io = JsonUtils.Deserialize <InputOption>(payload.ToString());
                            cloverConnector.InvokeInputOption(io);
                            break;
                        }

                        case WebSocketMethod.VoidPayment:
                        {
                            VoidPaymentRequest request = JsonUtils.Deserialize <VoidPaymentRequest>(payload.ToString());
                            cloverConnector.VoidPayment(request);
                            break;
                        }

                        case WebSocketMethod.ManualRefund:
                        {
                            ManualRefundRequest mrr = JsonUtils.Deserialize <ManualRefundRequest>(payload.ToString());
                            cloverConnector.ManualRefund(mrr);
                            break;
                        }

                        case WebSocketMethod.RefundPayment:
                        {
                            RefundPaymentRequest request = JsonUtils.Deserialize <RefundPaymentRequest>(payload.ToString());
                            cloverConnector.RefundPayment(request);
                            break;
                        }

                        case WebSocketMethod.DisplayPaymentReceiptOptions:
                        {
                            DisplayPaymentReceiptOptionsRequest request = JsonUtils.Deserialize <DisplayPaymentReceiptOptionsRequest>(payload.ToString());
                            cloverConnector.DisplayPaymentReceiptOptions(request);
                            break;
                        }

                        case WebSocketMethod.ShowDisplayOrder:
                        {
                            com.clover.remote.order.DisplayOrder displayOrder = JsonUtils.Deserialize <com.clover.remote.order.DisplayOrder>(payload.ToString());
                            cloverConnector.ShowDisplayOrder(displayOrder);
                            break;
                        }

                        case WebSocketMethod.AcceptSignature:
                        {
                            WSVerifySignatureRequest svr = JsonUtils.Deserialize <WSVerifySignatureRequest>(payload.ToString());
                            cloverConnector.AcceptSignature(svr);
                            break;
                        }

                        case WebSocketMethod.RejectSignature:
                        {
                            WSVerifySignatureRequest svr = JsonUtils.Deserialize <WSVerifySignatureRequest>(payload.ToString());
                            cloverConnector.RejectSignature(svr);
                            break;
                        }

                        case WebSocketMethod.ConfirmPayment:
                        {
                            AcceptPayment acceptPayment = JsonUtils.Deserialize <AcceptPayment>(payload.ToString());
                            cloverConnector.AcceptPayment(acceptPayment.Payment);
                            break;
                        }

                        case WebSocketMethod.RejectPayment:
                        {
                            RejectPayment rp = JsonUtils.Deserialize <RejectPayment>(payload.ToString());
                            cloverConnector.RejectPayment(rp.Payment, rp.Challenge);
                            break;
                        }

                        case WebSocketMethod.VaultCard:
                        {
                            VaultCardMessage vcm = JsonUtils.Deserialize <VaultCardMessage>(payload.ToString());
                            cloverConnector.VaultCard(vcm.cardEntryMethods);
                            break;
                        }

                        case WebSocketMethod.ReadCardData:
                        {
                            ReadCardDataRequest request = JsonUtils.Deserialize <ReadCardDataRequest>(payload.ToString());
                            cloverConnector.ReadCardData(request);
                            break;
                        }

                        case WebSocketMethod.Closeout:
                        {
                            CloseoutRequest cr = new CloseoutRequest();
                            cloverConnector.Closeout(cr);
                            break;
                        }

                        case WebSocketMethod.RetrievePendingPayments:
                        {
                            cloverConnector.RetrievePendingPayments();
                            break;
                        }

                        case WebSocketMethod.StartCustomActivity:
                        {
                            CustomActivityRequest request = JsonUtils.Deserialize <CustomActivityRequest>(payload.ToString());
                            cloverConnector.StartCustomActivity(request);
                            break;
                        }

                        case WebSocketMethod.RetrieveDeviceStatus:
                        {
                            RetrieveDeviceStatusRequest request = JsonUtils.Deserialize <RetrieveDeviceStatusRequest>(payload.ToString());
                            cloverConnector.RetrieveDeviceStatus(request);
                            break;
                        }

                        case WebSocketMethod.SendMessageToActivity:
                        {
                            MessageToActivity mta = JsonUtils.Deserialize <MessageToActivity>(payload.ToString());
                            cloverConnector.SendMessageToActivity(mta);
                            break;
                        }

                        case WebSocketMethod.RetrievePaymentRequest:
                        {
                            RetrievePaymentRequest rpr = JsonUtils.Deserialize <RetrievePaymentRequest>(payload.ToString());
                            cloverConnector.RetrievePayment(rpr);
                            break;
                        }

                        case WebSocketMethod.RetrievePrintersRequest:
                        {
                            RetrievePrintersRequest rpr = JsonUtils.Deserialize <RetrievePrintersRequest>(payload.ToString());
                            cloverConnector.RetrievePrinters(rpr);
                            break;
                        }

                        case WebSocketMethod.PrintJobStatusRequest:
                        {
                            PrintJobStatusRequest req = JsonUtils.Deserialize <PrintJobStatusRequest>(payload.ToString());
                            cloverConnector.RetrievePrintJobStatus(req);
                            break;
                        }

                        case WebSocketMethod.PrintRequest:
                        {
                            PrintRequest64Message request      = JsonUtils.Deserialize <PrintRequest64Message>(payload.ToString());
                            PrintRequest          printRequest = null;
                            if (request.base64strings.Count > 0)
                            {
                                byte[]       imgBytes = Convert.FromBase64String(request.base64strings[0]);
                                MemoryStream ms       = new MemoryStream();
                                ms.Write(imgBytes, 0, imgBytes.Length);
                                Bitmap bp = new Bitmap(ms);
                                ms.Close();
                                printRequest = new PrintRequest(bp, request.externalPrintJobId, request.printDeviceId);
                            }
                            else if (request.imageUrls.Count > 0)
                            {
                                printRequest = new PrintRequest(request.imageUrls[0], request.externalPrintJobId, request.printDeviceId);
                            }
                            else if (request.textLines.Count > 0)
                            {
                                printRequest = new PrintRequest(request.textLines, request.externalPrintJobId, request.printDeviceId);
                            }
                            cloverConnector.Print(printRequest);
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("received unknown websocket method: " + method.ToString() + " in CloverWebSocketService.");
                            break;
                        }
                        }
                    }
                    catch (InvalidOperationException ioe)
                    {
                        Console.WriteLine(ioe.Message);
                        socket.Send("Error Deserializing");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        socket.Send("Error Parsing: " + message);
                    }
                };
            };

            InitializeConnector(parameters);
            server.Start(serverSocket);
        }
示例#5
0
 public void OnPrintJobStatusRequest(PrintJobStatusRequest request) => throw new NotImplementedException();
示例#6
0
 public virtual void OnPrintJobStatusRequest(PrintJobStatusRequest request)
 {
     Send("/PrintJobStatusRequest", Serialize(request));
 }
示例#7
0
 public void RetrievePrintJobStatus(PrintJobStatusRequest request)
 {
     Send("/RetrievePrintJobStatus", request);
 }
示例#8
0
        private void websocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            // do the parsing of the message, targeted for the callback listener
            JObject jsonObj = null;

            try
            {
                jsonObj = (JObject)JsonConvert.DeserializeObject(e.Message);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message + " => " + e.Message);
                listeners.ForEach(listener => listener.OnDeviceError(new CloverDeviceErrorEvent(CloverDeviceErrorEvent.CloverDeviceErrorType.EXCEPTION, 0, null, exc.Message + " => " + e.Message)));
                return;
            }

            JToken method = jsonObj.GetValue(ServicePayloadConstants.PROP_METHOD);

            if (method == null)
            {
                listeners.ForEach(listener => listener.OnDeviceError(new CloverDeviceErrorEvent(CloverDeviceErrorEvent.CloverDeviceErrorType.VALIDATION_ERROR, 0, null, "Invalid message: " + e.Message)));
                return;
            }
            JObject         payload = (JObject)jsonObj.GetValue(ServicePayloadConstants.PROP_PAYLOAD);
            WebSocketMethod wsm     = (WebSocketMethod)Enum.Parse(typeof(WebSocketMethod), method.ToString());

            try
            {
                switch (wsm)
                {
                case WebSocketMethod.DeviceActivityStart:
                {
                    CloverDeviceEvent deviceEvent = JsonUtils.Deserialize <CloverDeviceEvent>(payload.ToString());
                    listeners.ForEach(listener => listener.OnDeviceActivityStart(deviceEvent));
                    break;
                }

                case WebSocketMethod.DeviceActivityEnd:
                {
                    CloverDeviceEvent deviceEvent = JsonUtils.Deserialize <CloverDeviceEvent>(payload.ToString());
                    listeners.ForEach(listener => listener.OnDeviceActivityEnd(deviceEvent));
                    break;
                }

                case WebSocketMethod.DeviceError:
                {
                    CloverDeviceErrorEvent deviceErrorEvent = JsonUtils.Deserialize <CloverDeviceErrorEvent>(payload.ToString());
                    listeners.ForEach(listener => listener.OnDeviceError(deviceErrorEvent));
                    break;
                }

                case WebSocketMethod.DeviceConnected:
                {
                    listeners.ForEach(listener => listener.OnDeviceConnected());
                    break;
                }

                case WebSocketMethod.DeviceDisconnected:
                {
                    listeners.ForEach(listener => listener.OnDeviceDisconnected());
                    break;
                }

                case WebSocketMethod.DeviceReady:
                {
                    MerchantInfo merchantInfo = JsonUtils.Deserialize <MerchantInfo>(payload.ToString());
                    listeners.ForEach(listener => listener.OnDeviceReady(merchantInfo));
                    break;
                }

                case WebSocketMethod.VerifySignatureRequest:
                {
                    VerifySignatureRequest        svr     = JsonUtils.Deserialize <VerifySignatureRequest>(payload.ToString());
                    WebSocketSigVerRequestHandler handler = new WebSocketSigVerRequestHandler(this, svr);
                    listeners.ForEach(listener => listener.OnVerifySignatureRequest(handler));
                    break;
                }

                case WebSocketMethod.SaleResponse:
                {
                    SaleResponse sr = JsonUtils.Deserialize <SaleResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnSaleResponse(sr));
                    break;
                }

                case WebSocketMethod.PreAuthResponse:
                {
                    PreAuthResponse pr = JsonUtils.Deserialize <PreAuthResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPreAuthResponse(pr));
                    break;
                }

                case WebSocketMethod.AuthResponse:
                {
                    AuthResponse ar = JsonUtils.Deserialize <AuthResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnAuthResponse(ar));
                    break;
                }

                case WebSocketMethod.CapturePreAuthResponse:
                {
                    CapturePreAuthResponse ar = JsonUtils.Deserialize <CapturePreAuthResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnCapturePreAuthResponse(ar));
                    break;
                }

                case WebSocketMethod.VoidPaymentRefundResponse:
                {
                    VoidPaymentRefundResponse response = JsonUtils.Deserialize <VoidPaymentRefundResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnVoidPaymentRefundResponse(response));
                    break;
                }

                case WebSocketMethod.RefundPaymentResponse:
                {
                    RefundPaymentResponse sr = JsonUtils.Deserialize <RefundPaymentResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnRefundPaymentResponse(sr));
                    break;
                }

                case WebSocketMethod.VoidPaymentResponse:
                {
                    VoidPaymentResponse sr = JsonUtils.Deserialize <VoidPaymentResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnVoidPaymentResponse(sr));
                    break;
                }

                case WebSocketMethod.ManualRefundResponse:
                {
                    ManualRefundResponse sr = JsonUtils.Deserialize <ManualRefundResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnManualRefundResponse(sr));
                    break;
                }

                case WebSocketMethod.TipAdjustAuthResponse:
                {
                    TipAdjustAuthResponse taar = JsonUtils.Deserialize <TipAdjustAuthResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnTipAdjustAuthResponse(taar));
                    break;
                }

                case WebSocketMethod.VaultCardResponse:
                {
                    VaultCardResponse vcr = JsonUtils.Deserialize <VaultCardResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnVaultCardResponse(vcr));
                    break;
                }

                case WebSocketMethod.ReadCardDataResponse:
                {
                    ReadCardDataResponse rcdr = JsonUtils.Deserialize <ReadCardDataResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnReadCardDataResponse(rcdr));
                    break;
                }

                case WebSocketMethod.CloseoutResponse:
                {
                    CloseoutResponse cr = JsonUtils.Deserialize <CloseoutResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnCloseoutResponse(cr));
                    break;
                }

                case WebSocketMethod.ConfirmPaymentRequest:
                {
                    ConfirmPaymentRequest cpr = JsonUtils.Deserialize <ConfirmPaymentRequest>(payload.ToString());
                    listeners.ForEach(listener => listener.OnConfirmPaymentRequest(cpr));
                    break;
                }

                case WebSocketMethod.RetrievePendingPaymentsResponse:
                {
                    RetrievePendingPaymentsResponse rppr = JsonUtils.Deserialize <RetrievePendingPaymentsResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnRetrievePendingPaymentsResponse(rppr));
                    break;
                }

                case WebSocketMethod.PrintManualRefundDeclinedReceipt:
                {
                    PrintManualRefundDeclineReceiptMessage pmrdrm = JsonUtils.Deserialize <PrintManualRefundDeclineReceiptMessage>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintManualRefundDeclineReceipt(pmrdrm));
                    break;
                }

                case WebSocketMethod.PrintManualRefundReceipt:
                {
                    PrintManualRefundReceiptMessage pmrrm = JsonUtils.Deserialize <PrintManualRefundReceiptMessage>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintManualRefundReceipt(pmrrm));
                    break;
                }

                case WebSocketMethod.PrintPaymentDeclinedReceipt:
                {
                    PrintPaymentDeclineReceiptMessage ppdrm = JsonUtils.Deserialize <PrintPaymentDeclineReceiptMessage>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintPaymentDeclineReceipt(ppdrm));
                    break;
                }

                case WebSocketMethod.PrintPaymentMerchantCopyReceipt:
                {
                    PrintPaymentMerchantCopyReceiptMessage ppmcrm = JsonUtils.Deserialize <PrintPaymentMerchantCopyReceiptMessage>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintPaymentMerchantCopyReceipt(ppmcrm));
                    break;
                }

                case WebSocketMethod.PrintPaymentReceipt:
                {
                    PrintPaymentReceiptMessage pprm = JsonUtils.Deserialize <PrintPaymentReceiptMessage>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintPaymentReceipt(pprm));
                    break;
                }

                case WebSocketMethod.PrintPaymentRefundReceipt:
                {
                    PrintRefundPaymentReceiptMessage prprm = JsonUtils.Deserialize <PrintRefundPaymentReceiptMessage>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintRefundPaymentReceipt(prprm));
                    break;
                }

                case WebSocketMethod.CustomActivityResponse:
                {
                    CustomActivityResponse car = JsonUtils.Deserialize <CustomActivityResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnCustomActivityResponse(car));
                    break;
                }

                case WebSocketMethod.MessageFromActivity:
                {
                    MessageFromActivity mta = JsonUtils.Deserialize <MessageFromActivity>(payload.ToString());
                    listeners.ForEach(listener => listener.OnMessageFromActivity(mta));
                    break;
                }

                case WebSocketMethod.RetrieveDeviceStatusResponse:
                {
                    RetrieveDeviceStatusResponse rdsr = JsonUtils.Deserialize <RetrieveDeviceStatusResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnRetrieveDeviceStatusResponse(rdsr));
                    break;
                }

                case WebSocketMethod.ResetDeviceResponse:
                {
                    ResetDeviceResponse rdr = JsonUtils.Deserialize <ResetDeviceResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnResetDeviceResponse(rdr));
                    break;
                }

                case WebSocketMethod.RetrievePaymentResponse:
                {
                    RetrievePaymentResponse rpr = JsonUtils.Deserialize <RetrievePaymentResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnRetrievePaymentResponse(rpr));
                    break;
                }

                case WebSocketMethod.RetrievePrintersResponse:
                {
                    RetrievePrintersResponse rpr = JsonUtils.Deserialize <RetrievePrintersResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnRetrievePrintersResponse(rpr));
                    break;
                }

                case WebSocketMethod.PrintJobStatusRequest:
                {
                    PrintJobStatusRequest pjsr = JsonUtils.Deserialize <PrintJobStatusRequest>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintJobStatusRequest(pjsr));
                    break;
                }

                case WebSocketMethod.PrintJobStatusResponse:
                {
                    PrintJobStatusResponse pjsr = JsonUtils.Deserialize <PrintJobStatusResponse>(payload.ToString());
                    listeners.ForEach(listener => listener.OnPrintJobStatusResponse(pjsr));
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#9
0
 public void OnPrintJobStatusRequest(PrintJobStatusRequest request)
 {
     Program.WriteLine(MethodBase.GetCurrentMethod().Name);
 }