Пример #1
0
        private static Iso8583Message SendResponseMessage(ListenerPeer listenerPeer, Iso8583Message message)
        {
            bool    needReversal       = false;
            int     maxNumberOfEntries = 3;
            Message response           = null;
            int     serverTimeOut      = 60000;

            PeerRequest request = null;

            try
            {
                if (listenerPeer.IsConnected)
                {
                    request = new PeerRequest(listenerPeer, message);
                    request.Send();
                    request.WaitResponse(serverTimeOut);
                    if (request.Expired)
                    {
                        //logger.Log("Connection timeout.");
                        needReversal = true;
                        return(SetResponseMessage(message, "68")); //Response received too late
                    }

                    if (request != null)
                    {
                        response = request.ResponseMessage;
                        //logger.Log("Message Recieved From FEP");
                    }

                    //
                    //request.MarkAsExpired();   //uncomment to test timeout
                    return(response as Iso8583Message);
                }
                else
                {
                    //logger.Log("Could not connect to Sink Node");
                    //clientPeer.Close();
                    listenerPeer.Close();
                    Console.WriteLine("Client Peer is not Connected");
                    return(SetResponseMessage(message, "91"));
                }

                //clientPeer.Close();
            }
            catch (Exception e)
            {
                //logger.Log("An error occured " + e.Message);
                return(SetResponseMessage(message, "06"));
            }
        }
Пример #2
0
        private void ListenerPeerReceive(object sender, ReceiveEventArgs e)
        {
            ListenerPeer   listenerPeer = sender as ListenerPeer;
            Iso8583Message message      = e.Message as Iso8583Message;

            if (message == null)
            {
                return;
            }

            //logger.Log("Receiving Message >>>>");

            Processor      processor = new Processor();
            Iso8583Message response;

            try
            {
                processor.LogTransaction(message);

                if (message.IsReversalOrChargeBack())
                {
                    response = processor.Process(message);
                }
                else
                {
                    response = processor.Process(message);
                }

                processor.LogTransaction(response);
                //logger.Log("Sending Response >>>>");
            }
            catch (Exception ex)
            {
                message.Fields.Add(39, "06");
                message.SetResponseMessageTypeIdentifier();
                processor.LogTransaction(message);
                response = message;

                //processor.LogTransaction(response);
                //logger.Log("Error, Something went wrong somewhere");
            }

            listenerPeer.Send(response);
            listenerPeer.Close();
            listenerPeer.Dispose();
        }
Пример #3
0
        private void Listener_Receive(object sender, ReceiveEventArgs e)
        {
            //Cast event sender as ClientPeer
            ListenerPeer sourcePeer = sender as ListenerPeer;

            Logger.Log("Listener Peer is now receiving..." + DateTime.Now.ToString("dd/MMM/yyyy hh:mm:ss tt") + Environment.NewLine);
            //Get the Message received
            Iso8583Message incomingMessage = e.Message as Iso8583Message;

            if (incomingMessage == null)
            {
                return;
            }
            long           sourceID        = Convert.ToInt64(sourcePeer.Name); //where message is coming from
            Iso8583Message receivedMessage = new TransactionManager().ValidateMessage(incomingMessage, Convert.ToInt32(sourceID));

            sourcePeer.Send(receivedMessage);
            sourcePeer.Close();
            sourcePeer.Dispose();
        }