Example #1
0
        private void OnPostScanQrReceived(IAWAppScanReply reply)
        {
            Logger.Debug(GetType(), "OnPostScanQrReceived() for webRequestId={0} received={1} hasOnSuccess?={2} hasOnError?={3}",
                         _webRequestId, reply, _onSuccess != null, _onError != null);

            var onSuccess = _onSuccess;

            _onSuccess = null;

            var onError = _onError;

            _onError = null;

            if (onSuccess == null || onError == null)
            {
                _queued.Add(reply);
                return;
            }

            var res = ReplyToTuple(reply);

            if (res != null)
            {
                onSuccess.Invoke(res);
            }
        }
Example #2
0
        private Tuple <ScanResultType, string> ReplyToTuple(IAWAppScanReply reply)
        {
            Logger.Debug(GetType(), "OnPostScanQrReceived() for webRequestId={0} received={1}",
                         _webRequestId, reply);

            if (reply.IsDisposal)
            {
                _disposed = true;
                Logger.Debug(GetType(), "OnPostScanQrReceived() disposed");
                return(Tuple.Create(ScanResultType.Disposed, (string)null));
            }

            if (reply.IsPaused)
            {
                Logger.Debug(GetType(), "OnPostScanQrReceived() paused");
                return(Tuple.Create(ScanResultType.Paused, (string)null));
            }

            if (reply.IsCancellation)
            {
                _cancellationConfirmed = true;
                Logger.Debug(GetType(), "OnPostScanQrReceived() cancelled");
                return(Tuple.Create(ScanResultType.Cancelled, (string)null));
            }

            Logger.Debug(GetType(), "OnPostScanQrReceived() scanned");
            return(Tuple.Create(ScanResultType.Scanned, reply.Barcode));
        }