Example #1
0
        static void Main(string[] args)
        {
            log.Debug("--> Main");

            SocketListener listener = new SocketListener();

            IMessageFactory factory = new MessageFactoryFIX(ConfigurationManager.AppSettings["BeginString"]);

            //IMessageFactory factory = new FIX_4_2.MessageFactoryFIX();
            _factory = factory;

            IEngine engine = new SocketEngine();

            engine.MessageCacheFactory = new MessageCacheFlatFileFactory();
            engine.MessageFactory      = factory;
            engine.Initialize(
                ConfigurationManager.AppSettings["SenderCompID"], null,
                ConfigurationManager.AppSettings["TargetCompID"], null);
            engine.Received += new MessageEventHandler(engine_Received);
            engine.Sent     += new MessageEventHandler(engine_Sent);

            listener.Add(engine);

            int port = int.Parse(ConfigurationManager.AppSettings["Port"]);

            listener.Init(port);

            Console.WriteLine("press <Enter> to exit...");
            Console.ReadLine();

            listener.Dispose();
            engine.Dispose();

            log.Debug("<-- Main");
        }
        public void TestFixtureSetUp()
        {
            engineListen = new SocketEngine();
            engineListen.MessageCacheFactory = new MessageCacheFlatFileFactory();
            engineListen.MessageFactory      = factory;
            engineListen.AllowOfflineSend    = true;
            engineListen.Initialize("LISTEN", "CONNECT");
            engineListen.Received += new MessageEventHandler(engineListen_Received);
            engineListen.Sent     += new MessageEventHandler(engineListen_Sent);

            listener = new SocketListener();
            listener.Add(engineListen);
            listener.Init(9050);

            engineConnect = new SocketEngine();
            engineConnect.MessageCacheFactory = new MessageCacheFlatFileFactory();
            engineConnect.MessageFactory      = factory;
            engineConnect.AllowOfflineSend    = true;
            engineConnect.Initialize("CONNECT", "LISTEN");
            engineConnect.Received += new MessageEventHandler(engineConnect_Received);
            engineConnect.Sent     += new MessageEventHandler(engineConnect_Sent);
        }