Пример #1
0
        internal WorkContext(WaveServer server, HttpListenerContext listenerContext)
        {
            m_Server          = server;
            m_ListenerContext = listenerContext;
            m_Response        = new Response(this, listenerContext.Response);

            ApplicationModel.ExecutionContext.__SetThreadLevelContext(this, m_Response, null);
            Interlocked.Increment(ref m_Server.m_Stat_WorkContextCtor);
        }
Пример #2
0
      internal WorkContext(WaveServer server, HttpListenerContext listenerContext)
      {
        m_Server = server;
        m_ListenerContext = listenerContext;
        m_Response = new Response(this, listenerContext.Response);

        ApplicationModel.ExecutionContext.__SetThreadLevelContext(this, m_Response, null);
        Interlocked.Increment(ref m_Server.m_Stat_WorkContextCtor);
      }
Пример #3
0
        internal WorkContext(WaveServer server, HttpListenerContext listenerContext)
        {
            m_ID              = Guid.NewGuid();
            m_Server          = server;
            m_ListenerContext = listenerContext;
            m_Response        = new Response(this, listenerContext.Response);

            ats_Current.Value = this;
            Interlocked.Increment(ref m_Server.m_stat_WorkContextCtor);
        }
Пример #4
0
        protected WorkFilter(WorkDispatcher dispatcher, string name, int order)
            : base(dispatcher)
        {
            if (name.IsNullOrWhiteSpace()||dispatcher==null)
             throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(dispatcher|name==null|empty)");

            m_Name = name;
            m_Dispatcher = dispatcher;
            m_Server = dispatcher.ComponentDirector;
            m_Order = order;
        }
Пример #5
0
        protected WorkFilter(WorkDispatcher dispatcher, IConfigSectionNode confNode)
            : base(dispatcher)
        {
            if (confNode==null||dispatcher==null)
             throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(dispatcher|confNode==null|empty)");

            m_Dispatcher = dispatcher;
            m_Server = dispatcher.ComponentDirector;
            m_Name = confNode.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
            m_Order = confNode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0);

            if (m_Name.IsNullOrWhiteSpace())
             throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(confNode$name==null|empty)");
        }
Пример #6
0
        protected WorkHandler(WorkDispatcher dispatcher, string name, int order, WorkMatch match)
            : base(dispatcher)
        {
            if (dispatcher==null)
             throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(dispatcher==null|empty)");

            if (name.IsNullOrWhiteSpace())
              name = "{0}({1})".Args(GetType().FullName, Guid.NewGuid());

            m_Name = name;
            m_Dispatcher = dispatcher;
            m_Server = dispatcher.ComponentDirector;
            m_Order = order;
            if (match!=null)
             m_Matches.Register(match);
        }
Пример #7
0
 static void Main(string[] args)
 {
     try
     {
         using (var app = new ServiceBaseApplication(args, null))
         using (var server = new WaveServer())
         {
             server.Configure(null);
             server.Start();
             Console.WriteLine("server started...");
             Console.ReadLine();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Critical error:");
         Console.WriteLine(ex);
         Environment.ExitCode = -1;
     }
 }
Пример #8
0
 static void Main(string[] args)
 {
     try
     {
        using(new ServiceBaseApplication(args, null))
      using(var ws = new WaveServer())
      {
         ws.Configure(null);
         ws.Start();
         Console.WriteLine("Web server started. Press <ENTER> to terminate...");
         Console.ReadLine();
      }
     }
     catch(Exception error)
     {
       Console.WriteLine("Exception leaked");
       Console.WriteLine("----------------");
       Console.WriteLine(error.ToMessageWithType());
       System.Environment.ExitCode = -1;
     }
 }
Пример #9
0
 static void Main(string[] args)
 {
     try
     {
         using (var app = new ServiceBaseApplication(args, null))
         using (var server = new WaveServer())
         {
             server.Configure(null);
             server.Start();
             Console.WriteLine("Web server started at {0}.", DateTime.Now);
             Console.WriteLine("Press <ENTER> to terminate...");
             Console.ReadLine();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Critical error:");
         Console.WriteLine(ex.ToMessageWithType());
         Environment.ExitCode = -1;
     }
 }
Пример #10
0
        protected WorkHandler(WorkDispatcher dispatcher, IConfigSectionNode confNode)
            : base(dispatcher)
        {
            if (confNode==null||dispatcher==null)
             throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(dispatcher|confNode==null|empty)");

            m_Dispatcher = dispatcher;
            m_Server = dispatcher.ComponentDirector;
            m_Name = confNode.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
            m_Order = confNode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0);
            if (m_Name.IsNullOrWhiteSpace())
             m_Name = "{0}({1})".Args(GetType().FullName, Guid.NewGuid());

            foreach(var cn in confNode.Children.Where(cn=>cn.IsSameName(WorkFilter.CONFIG_FILTER_SECTION)))
              if(!m_Filters.Register( FactoryUtils.Make<WorkFilter>(cn, typeof(WorkFilter), args: new object[]{ this, cn })) )
            throw new WaveException(StringConsts.CONFIG_HANDLER_DUPLICATE_FILTER_NAME_ERROR.Args(cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value));

            foreach(var cn in confNode.Children.Where(cn=>cn.IsSameName(WorkMatch.CONFIG_MATCH_SECTION)))
              if(!m_Matches.Register( FactoryUtils.Make<WorkMatch>(cn, typeof(WorkMatch), args: new object[]{ cn })) )
            throw new WaveException(StringConsts.CONFIG_HANDLER_DUPLICATE_MATCH_NAME_ERROR.Args(cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value));
        }
Пример #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (m_Server!=null) return;

             // System.Threading.ThreadPool.SetMaxThreads(1024, 1024);

              m_Server = new WaveServer();
              m_Server.Configure(null);
              try
              {
               // m_Server.Prefixes.Add(tbPrefix.Text);
               // m_Server.KernelHttpQueueLimit = 1;//0000;
               // m_Server.ParallelAccepts = 2;
            m_Server.Start();
              }
              catch
              {
            m_Server.Dispose();
            m_Server = null;
            throw;
              }
        }
Пример #12
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (m_Server==null) return;
        m_Server.Dispose();
        m_Server = null;
 }