Inheritance: LogFactory
コード例 #1
0
ファイル: Program.cs プロジェクト: nisbus/quickfixn
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("usage: SimpleAcceptor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                Application app = new SimpleAcceptorApp();
                MessageStoreFactory storeFactory = new FileStoreFactory(settings);
                LogFactory logFactory = new FileLogFactory(settings);
                IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: gbirchmeier/QfnDemoApps
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is for evaluating new QF/n builds and features.");
            Console.WriteLine("It's designed to communicate with PilotAcceptor44.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                System.Console.WriteLine("usage: PilotInitiator44.exe CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            string file = args[0];

            try
            {
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings(file);
                PilotInit44App myApp = new PilotInit44App();
                QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                QuickFix.ILogFactory logFactory = new QuickFix.FileLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(myApp, storeFactory, settings, logFactory);

                initiator.Start();
                myApp.Run();
                initiator.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: gbirchmeier/QfnDemoApps
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is for evaluating new QF/n builds and features.");
            Console.WriteLine("It's designed to communicate with PilotInitiator44.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                Console.WriteLine("usage: PilotAcceptorr44 CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                IApplication myApp = new PilotAcc44App();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = new FileLogFactory(settings);
                ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(myApp, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: RemiGaudin/quickfixn
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is only an example program, meant to be used with the TradeClient example.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                Console.WriteLine("usage: Executor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                IApplication executorApp = new Executor();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = new FileLogFactory(settings);
                ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(executorApp, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #5
0
ファイル: GSFIXTrade.cs プロジェクト: sharespy/csharp-project
 private void Init()
 {
     this.settings            = new QuickFix.SessionSettings(this.settingFile);
     this.messageStoreFactory = new QuickFix.FileStoreFactory(this.settings);
     this.logFactory          = new QuickFix.FileLogFactory(this.settings);
     this.messageFactory      = new QuickFix42.MessageFactory();
     this.socketInitiator     = new QuickFix.SocketInitiator(this, this.messageStoreFactory, this.settings, this.logFactory, this.messageFactory);
 }
コード例 #6
0
ファイル: GSFIXTrade.cs プロジェクト: sharespy/csharp-project
 public void Close()
 {
     //this.socketInitiator.stop();
     this.ssnid               = null;
     this.socketInitiator     = null;
     this.messageStoreFactory = null;
     this.settings            = null;
     this.logFactory          = null;
     this.messageFactory      = null;
 }
コード例 #7
0
        public void Connect(IApplication application)
        {
            var settings = new SessionSettings("session.config");
            var myApp = application;
            var storeFactory = new FileStoreFactory(settings);
            var logFactory = new FileLogFactory(settings);

            initiator = new SocketInitiator(myApp, storeFactory, settings, logFactory);

            initiator.Start();
        }
コード例 #8
0
ファイル: ATRunner.cs プロジェクト: RemiGaudin/quickfixn
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.WriteLine("usage: AcceptanceTest CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            FileLog debugLog = new FileLog("log", new SessionID("AT", "Application", "Debug")); 
            ThreadedSocketAcceptor acceptor = null;
            try
            {
                ATApplication testApp = new ATApplication(debugLog);
                testApp.StopMeEvent += new System.Action(delegate() { _stopMe = true; });
                
                SessionSettings settings = new SessionSettings(args[0]);
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = null;
                if (settings.Get().Has("Verbose") && settings.Get().GetBool("Verbose"))
                    logFactory = new FileLogFactory(settings);
                acceptor = new ThreadedSocketAcceptor(testApp, storeFactory, settings, logFactory);

                acceptor.Start();
                while (true)
                {
                    System.Console.WriteLine("o hai "+System.DateTime.Now.ToString());
                    System.Threading.Thread.Sleep(1000);

                    // for tests of logout
                    if (_stopMe)
                    {
                        // this doesn't seem to work
                        // after stop, it doesn't seem to start up again
                        /*
                        acceptor.Stop();
                        Thread.Sleep(5 * 1000);
                        _stopMe = false;
                        acceptor.Start();
                         */
                    }
                }
            }
            catch (System.Exception e)
            {
                debugLog.OnEvent(e.ToString());
            }

            finally
            {
                if(acceptor != null)
                    acceptor.Stop();
            }
            
        }
コード例 #9
0
        /// <summary>
        /// Connects/Starts a client
        /// </summary>
        public bool Start()
        {
            try
            {
                if (this._initiator == null)
                {
                    PopulateFixSettings();

                    QuickFix.SessionSettings      settings       = new QuickFix.SessionSettings(this._fixSettingsFile);
                    IApplication                  application    = this;
                    QuickFix.FileStoreFactory     storeFactory   = new QuickFix.FileStoreFactory(settings);
                    QuickFix.FileLogFactory       logFactory     = new QuickFix.FileLogFactory(settings);
                    QuickFix.IMessageStoreFactory messageFactory = new QuickFix.FileStoreFactory(settings);

                    this._initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);

                    this._initiator.Start();

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info("Integral Data Client Started.", _type.FullName, "Start");
                    }
                }
                else
                {
                    if (!this._initiator.IsStopped)
                    {
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info("Integral Data Client Already Started.", _type.FullName, "Start");
                        }
                    }
                    else
                    {
                        this._initiator.Start();
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info("Integral Data Client Started.", _type.FullName, "Start");
                        }
                    }
                }

                return(true);
            }
            catch (Exception exception)
            {
                Logger.Error(exception.ToString(), _type.FullName, "Start");
            }
            return(false);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: naziway/testtask
        static void Main(string[] args)
        {
            var settingsFile = "FixAtServer.cfg";
            if (args.Length >= 1)
            {
                settingsFile = args[0];
            }

            Console.WriteLine("Starting server ...");
            try
            {
                var settings = new SessionSettings(settingsFile);
                var server = new ServerApplication(Console.WriteLine);
                var storeFactory = new FileStoreFactory(settings);
                var logFactory = new FileLogFactory(settings);
                var acceptor = new ThreadedSocketAcceptor(server,
                                                          storeFactory,
                                                          settings,
                                                          logFactory);

                acceptor.Start();
                Console.WriteLine("Server started");
                Console.WriteLine("Press Ctrl-C to quit");
                // TODO A better stop mechanism!

                // http://stackoverflow.com/questions/177856/how-do-i-trap-ctrl-c-in-a-c-sharp-console-app
                Console.CancelKeyPress += (sender, e) =>
                    {
                        Console.WriteLine("Stopping server ...");
                        acceptor.Stop();
                        server.Stop();
                        Console.WriteLine("Server stopped");
                    };

                while (true)
                {
                    System.Threading.Thread.Sleep(1000);
                }

            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e);
            }
        }
コード例 #11
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // FIX app settings and related
            var settings = new SessionSettings("C:\\initiator.cfg");

            // FIX application setup
            MessageStoreFactory storeFactory = new FileStoreFactory(settings);
            LogFactory logFactory = new FileLogFactory(settings);
            _client = new FixClient50Sp2(settings);

            IInitiator initiator = new SocketInitiator(_client, storeFactory, settings, logFactory);
            _client.Initiator = initiator;

            _client.OnProgress += _client_OnProgress;
            _client.LogonEvent += ClientLogonEvent;
            _client.MessageEvent += ClientMessageEvent;
            _client.LogoutEvent += ClientLogoutEvent;
            _client.OnMarketDataIncrementalRefresh += Client_OnMarketDataIncrementalRefresh;
        }
コード例 #12
0
ファイル: FIXApplication.cs プロジェクト: benofben/implier
        public FixApplication(String configFile)
        {
            try
            {
                logonCount = 0;
                Current = this;
                settings = new SessionSettings(configFile);
                storeFactory = new FileStoreFactory(settings);
                logFactory = new FileLogFactory(settings);
                messageFactory = new DefaultMessageFactory();
                SetSessionIndexes(configFile);

                initiator = new SocketInitiator(this, storeFactory, settings, logFactory, messageFactory);
                initiator.start();
                AddText("Created initiator." + Environment.NewLine);
            }
            catch (Exception exception)
            {
                AddText(exception.Message + Environment.NewLine);
                throw;
            }
        }
コード例 #13
0
ファイル: AccProgram.cs プロジェクト: gbirchmeier/QfnDemoApps
        static void Main(string[] args)
        {
            Console.WriteLine("=== CharEncoding Acceptor startup");

            try
            {
                SessionSettings settings = new SessionSettings("acceptor.cfg");
                IApplication app = new CEAcceptorApp();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = new FileLogFactory(settings);
                ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: BobRoss79/quickfixn
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is only an example program.");
            Console.WriteLine("It's a simple server (e.g. Acceptor) app that will let clients (e.g. Initiators)");
            Console.WriteLine("connect to it.  It will accept and display any application-level messages that it receives.");
            Console.WriteLine("Connecting clients should set TargetCompID to 'SIMPLE' and SenderCompID to 'CLIENT1' or 'CLIENT2'.");
            Console.WriteLine("Port is 5001.");
            Console.WriteLine("(see simpleacc.cfg for configuration details)");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                Console.WriteLine("usage: SimpleAcceptor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                Application app = new SimpleAcceptorApp();
                MessageStoreFactory storeFactory = new FileStoreFactory(settings);
                LogFactory logFactory = new FileLogFactory(settings);
                IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #15
0
        void StartEngine(bool initiator)
        {
            TestApplication application = new TestApplication(LogonCallback, LogoffCallback);
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            SessionSettings settings = new SessionSettings();
            Dictionary defaults = new Dictionary();
            defaults.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, LogPath);

            // Put IP endpoint settings into default section to verify that that defaults get merged into
            // session-specific settings not only for static sessions, but also for dynamic ones
            defaults.SetString(SessionSettings.SOCKET_CONNECT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_CONNECT_PORT, ConnectPort.ToString());
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_PORT, AcceptPort.ToString());

            settings.Set(defaults);
            ILogFactory logFactory = new FileLogFactory(settings);

            if (initiator)
            {
                defaults.SetString(SessionSettings.RECONNECT_INTERVAL, "1");
                settings.Set(CreateSessionID(StaticInitiatorCompID), CreateSessionConfig(StaticInitiatorCompID, true));
                _initiator = new SocketInitiator(application, storeFactory, settings, logFactory);
                _initiator.Start();
            }
            else
            {
                settings.Set(CreateSessionID(StaticAcceptorCompID), CreateSessionConfig(StaticAcceptorCompID, false));
                _acceptor = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);
                _acceptor.Start();
            }
        }
コード例 #16
0
 private void Init()
 {
     try
     {
         this._settings = new QuickFix.SessionSettings(settingfile);
         this._messageStoreFactory = new QuickFix.FileStoreFactory(this._settings);
         this._logFactory = new QuickFix.FileLogFactory(this._settings);
         this._messageFactory = new QuickFix42.MessageFactory();
         this._socketInitiator = new QuickFix.SocketInitiator  (this, _messageStoreFactory, this._settings, this._logFactory, _messageFactory);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #17
0
        public static void Main2(string[] args)
        {
            BTCCFIXClientApp app = new BTCCFIXClientApp();
            string sessionFile = Environment.CurrentDirectory+"/session_client.txt";
            SessionSettings settings = new SessionSettings(sessionFile);
            IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
            ILogFactory logFactory = new FileLogFactory(settings);
            QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(app, storeFactory, settings, logFactory);
            initiator.Start();

            BTCCMarketDataRequest btccDataRequest = new BTCCMarketDataRequest();

            System.Threading.Thread.Sleep(5000);
            //request full snapshot
            MarketDataRequest dataRequest = btccDataRequest.marketDataFullSnapRequest("BTCCNY");
            bool ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCBTC");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            System.Threading.Thread.Sleep(15000);
            //request incremental request
            dataRequest = btccDataRequest.marketDataIncrementalRequest("BTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCBTC");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            System.Threading.Thread.Sleep(40000);
            //unsubscribe incremental request
            dataRequest = btccDataRequest.unsubscribeIncrementalRequest("BTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCBTC");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);
        }
コード例 #18
0
ファイル: ServerQuickFix.cs プロジェクト: bluejack2000/core
 public bool Start(string user, string pw)
 {
     try
     {
         SessionSettings settings = new SessionSettings(_setpath);
         Application application = this;
         FileStoreFactory storeFactory = new FileStoreFactory(settings);
         FileLogFactory logFactory = new FileLogFactory(settings);
         MessageFactory messageFactory = new DefaultMessageFactory();
         acceptor = new SocketAcceptor
           (application, storeFactory, settings, logFactory /*optional*/, messageFactory);
         acceptor.start();
         _val = true;
         return true;
     }
     catch (Exception ex)
     {
         debug("exception starting server: " + ex.Message + ex.StackTrace);
         _val = false;
     }
     return false;
 }