Example #1
0
        static void Listener_Receive(object sender, ReceiveEventArgs e)
        {
            //Cast event sender as ClientPeer
            ListenerPeer sourcePeer = sender as ListenerPeer;

            // Get source node from client - client Name = SourceNode ID
            long sourceID = Convert.ToInt64(sourcePeer.Name); //wher message is coming from

            //then use the ID to retrieve the source node

            //Get the Message received
            Iso8583Message originalMessage = e.Message as Iso8583Message;

            //continue coding
            SourceNode sourceNode = new SourceNode
            {
                Name      = ConfigurationSettings.AppSettings["NodeNameTroughSwitch"],
                IPAddress = ConfigurationSettings.AppSettings["NodeIPThroughSwitch"],
                Port      = ConfigurationSettings.AppSettings["NodePortThroughSwitch"]
            };
            CheckSourceNode checkSourceNode = new CheckSourceNode();

            //checkSourceNode.SourceNode(sourceNode, originalMessage);
            checkSourceNode.SourceNode(originalMessage);
            //originalMessage.SetResponseMessageTypeIdentifier();
            sourcePeer.Send(originalMessage);
            sourcePeer.Listener.Start();
        }
        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();
        }
        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();
        }