示例#1
0
        public Server(NetMQContext context,  KeyValueDatabase db, params string[] addresses)
        {
            m_context = context;
            m_db = db;
            m_addresses = addresses;
            m_log = LogManager.GetLogger(this.GetType());

            if (!m_addresses.Any())
            {
                throw new ArgumentException("You must provide at least one address to listen too");
            }
        }
示例#2
0
        public void Stop()
        {
            m_log.InfoFormat("Stopping SharpDB...");

            m_server.Stop();
            m_task.Wait();

            m_db.Stop();
            m_context.Dispose();

            m_server = null;
            m_db = null;
            m_context = null;
        }
示例#3
0
        public void Start()
        {
            m_log = LogManager.GetLogger(this.GetType());

            m_log.InfoFormat("Starting SharpDB...");
            m_log.InfoFormat("Database Name: {0}", m_name);

            m_db = new KeyValueDatabase(filename => new DatabaseFileReader(filename), filename => new DatabaseFileWriter(filename),
                                                                     filename => new MemoryCacheProvider(filename));
            m_db.FileName = m_name + ".sdb";
            m_db.Start();

            m_context = NetMQContext.Create();

            m_server = new Network.Server(m_context, m_db, string.Format("tcp://*:{0}", m_port));

            m_task = Task.Factory.StartNew(m_server.Start);
        }