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(); }