Пример #1
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();
 }
        public static void Startup()
        {
            //TO INSTANTIATE CLIENT PEER
            TransactionManager trxnManager = new TransactionManager();
            //Start up all listeners
            Logger.Log("Searching for pre-configured source servers");
            List<SourceNode> allSourceNode = new SourceNodeManager().RetrieveAll().ToList();
            Logger.Log(allSourceNode.Count + " Source server(s) found:.\t ");

            new Listener().StartListener(allSourceNode);

            //Start up all clients
            Logger.Log("Searching for pre-configured sink Clients:-->> ");
            List<SinkNode> allSinkNode = new SinkNodeManager().GetAllSinkNode().ToList();
            Logger.Log(allSinkNode.Count + " Sink Client(s) found");
            new Client().StartClient(allSinkNode);
        }
        //Set status to inactive
        public static void Shutdown()
        {
            //TO INSTANTIATE CLIENT PEER
            TransactionManager trxnManager = new TransactionManager();

            IList<SourceNode> allSourceNode = new SourceNodeManager().RetrieveAll();

            foreach (var thisNode in allSourceNode)
            {
                thisNode.IsActive = false;
                new SourceNodeManager().Update(thisNode);
                Logger.Log(thisNode.Name + " shutting down at " + thisNode.IPAddress + " on " + thisNode.Port);
            }

            IList<SinkNode> SinkNodes = new SinkNodeManager().GetAllSinkNode();

            foreach (var sinkNode in SinkNodes)
            {
                sinkNode.IsActive = false;
                new SinkNodeManager().Update(sinkNode);
                Logger.Log(sinkNode.Name + " shutting down at " + sinkNode.IPAddress + " on " + sinkNode.Port);
                Console.WriteLine("SinkNode ShortDown" + sinkNode.IPAddress + "\t" + sinkNode.Port);
            }
        }