예제 #1
0
        public static void ListenerPeer(SourceNode sourceNode)     //create conn
        {
            TcpListener tcpListener = new TcpListener(Convert.ToInt32(sourceNode.Port));

            tcpListener.LocalInterface = sourceNode.IPAddress;
            ListenerPeer listener = new ListenerPeer(sourceNode.Id.ToString(),
                                                     new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()),
                                                     new BasicMessagesIdentifier(11, 41),
                                                     tcpListener);

            listener.Receive   += new PeerReceiveEventHandler(Listener_Receive);
            listener.Connected += listener_Connected;
            listener.Connect();

            Console.WriteLine("Listening for connection.. on " + sourceNode.Port);
        }
예제 #2
0
        public static void StartUpListener(string name, string hostName, int port)     //create conn
        {
            Trx.Messaging.FlowControl.TcpListener tcpListener = new Trx.Messaging.FlowControl.TcpListener(port);
            tcpListener.LocalInterface = hostName;
            ListenerPeer listener = new ListenerPeer(name,
                                                     new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()),
                                                     new BasicMessagesIdentifier(11, 41),
                                                     tcpListener);

            listener.Receive      += new PeerReceiveEventHandler(Listener_Receive);
            listener.Connected    += new PeerConnectedEventHandler(Listener_Connected);
            listener.Disconnected += new PeerDisconnectedEventHandler(Listener_Disconnected);
            listener.Connect();

            //Console.WriteLine("Waiting for connection...");
        }
예제 #3
0
        public void StartListener(SourceNode node)
        {
            TcpListener tcpListener = new TcpListener(node.Port);

            tcpListener.LocalInterface = node.IPAddress;
            ListenerPeer listener = new ListenerPeer(node.Id.ToString(),
                                                     new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()),
                                                     new BasicMessagesIdentifier(11, 41),
                                                     tcpListener);

            //            ListenerPeer
            listener.Error        += (sender, e) => ErrorListener(sender, e);
            listener.Receive      += (sender, e) => ReceiveListener(sender, e, node);
            listener.Disconnected += (sender, e) => DisconnectListener(sender, node);
            listener.Connect();
            Console.WriteLine($"Now listening to {node.Name} on IP {node.IPAddress} port {node.Port}");
        }
예제 #4
0
        public void StartListener(string ipAddress, int port, string id)
        {
            TcpListener tcpListener = new TcpListener(port);

            tcpListener.LocalInterface = ipAddress;
            ListenerPeer listener = new ListenerPeer(id,
                                                     new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()),
                                                     new BasicMessagesIdentifier(11, 41),
                                                     tcpListener);

            //            ListenerPeer
            listener.Error        += (sender, e) => ErrorListener(sender, e);
            listener.Receive      += (sender, e) => ReceiveListener(sender, e);
            listener.Disconnected += (sender, e) => DisconnectListener(sender);
            listener.Connect();
            Debug.WriteLine($"Now listening on IP {ipAddress} port {port}");
        }
예제 #5
0
        public void StartListener()
        {
            TcpListener tcpListener = new TcpListener(port);

            tcpListener.LocalInterface = localInterface;
            tcpListener.Start();

            ListenerPeer listenerPeer = new ListenerPeer("Switch", new TwoBytesNboHeaderChannel(
                                                             new Iso8583Ascii1987BinaryBitmapMessageFormatter()), tcpListener);

            //logger.Log("Phantom FEP now listening at " + localInterface + " on " + port);

            listenerPeer.Connected    += new PeerConnectedEventHandler(ListenerPeerConnected);
            listenerPeer.Receive      += new PeerReceiveEventHandler(ListenerPeerReceive);
            listenerPeer.Disconnected += new PeerDisconnectedEventHandler(ListenerPeerDisconnected);

            listenerPeer.Connect();
        }
예제 #6
0
        private static void SendSourceNodeResponse(ListenerPeer sourceNodePeer, Iso8583Message message)
        {
            int tries = 10;

            while (!sourceNodePeer.IsConnected && tries > 0)
            {
                Console.WriteLine("Could not connect to source node. Retrying in 5 seconds.");
                tries--;
                sourceNodePeer.Connect();
                Thread.Sleep(5000);
            }

            if (tries <= 0 && !sourceNodePeer.IsConnected)
            {
                Console.WriteLine("Reconnection attempt failed. Could not send response to source");
            }
            else
            {
                PeerRequest request = new PeerRequest(sourceNodePeer, message);
                request.Send();
                request.Peer.Close();
            }
        }