コード例 #1
0
        public virtual void OnPrintJobStatusResponse(PrintJobStatusResponse response)
        {
            OnPrintJobStatusResponseMessage msg = new OnPrintJobStatusResponseMessage();

            msg.payload = response;
            WebSocket.Send(Serialize(msg));
        }
コード例 #2
0
 public void PrintJobStatusResponse(HttpListenerContext context)
 {
     try
     {
         PrintJobStatusResponse pjsr = ParseResponse <PrintJobStatusResponse>(context);
         connectorListener.ForEach(listener => listener.OnPrintJobStatusResponse(pjsr));
     }
     catch (Exception e)
     {
         context.Response.StatusCode        = 400;
         context.Response.StatusDescription = e.Message;
         SendTextResponse(context, "error processing request");
     }
 }
コード例 #3
0
ファイル: Listener.cs プロジェクト: jwhitted-clover/jester
 public void OnPrintJobStatusResponse(PrintJobStatusResponse response) => Event?.Invoke(this, EventFrom("PrintJobStatusResponse", response));
コード例 #4
0
 public virtual void OnPrintJobStatusResponse(PrintJobStatusResponse response)
 {
     Send("/PrintJobStatusResponse", Serialize(response));
 }
コード例 #5
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);
            }
        }
コード例 #6
0
 public void OnPrintJobStatusResponse(PrintJobStatusResponse response)
 {
     Program.WriteLine(MethodBase.GetCurrentMethod().Name);
 }
コード例 #7
0
 public void OnPrintJobStatusResponse(PrintJobStatusResponse response) => PrintJobStatusResponse?.Invoke(this, response);