Esempio n. 1
0
        /// <summary>
        /// Traps and handles the peer RequestDone event.
        /// </summary>
        /// <param name="sender">
        /// The <see cref="Peer"/> sending the event.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        private void OnPeerRequestDone(object sender, PeerRequestDoneEventArgs e)
        {
            if ((e.Request.Payload != null) && (e.Request.Payload is IMessageSource))
            {
                IMessageSource source = ( IMessageSource)(e.Request.Payload);

                if (source.IsConnected)
                {
                    source.Send(e.Request.ResponseMessage);
                }
            }
        }
        public bool Process(IMessageSource source, Message message)
        {
            try
            {
                string         postBridgeNodeIp = (source as ServerPeer).Channel.Name;
                Iso8583Message theMsg           = message as Iso8583Message;
                if (TheBridge.PostBridgeNodePeer != null && TheBridge.PostBridgeNodePeer.Channel != null &&
                    postBridgeNodeIp == TheBridge.PostBridgeNodePeer.Channel.Name && !theMsg.IsRequest())
                {
                    if (_theBridge.PosRequestPeer.IsConnected)
                    {
                        _theBridge.PosRequestPeer.Send(message);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                bool isSignOnMessage = false;
                new PANE.ERRORLOG.Error().LogInfo("Request message: " + theMsg.ToString());
                PostBridge.Server.Messages.Message requestMessage = MessageParser.Read(theMsg, out isSignOnMessage);
                if (requestMessage.Validate())
                {
                    Iso8583Message msg = requestMessage.Execute();
                    new PANE.ERRORLOG.Error().LogInfo("About to send Response message: " + msg.ToString());
                    source.Send(msg);

                    //If is first sign on message, send Keyexchange.
                    if (!PinConfigurationManager.FepConfig.KeyExchangeOnConnect && lastKeyExchangeDate.Date != DateTime.Today && isSignOnMessage)
                    {
                        new BasicServerPeerManager2().DoKeyExchange(null);
                        lastKeyExchangeDate = DateTime.Now;
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                new PANE.ERRORLOG.Error().LogToFile(e);
                Logger.Error(e);
                return(false);
            }
        }