public SocketServerBase(IAppServer appServer, ListenerInfo[] listeners)
 {
     AppServer = appServer;
     IsRunning = false;
     ListenerInfos = listeners;
     Listeners = new List<ISocketListener>(listeners.Length);
 }
        public PerfMonitorForm( IAppServer server )
        {
            InitializeComponent();

            var couners = new PerformanceCounters( server );
            couners.StatUpdated += StatUpdated;
            Presenter = new PerfMonitorFormPresenter( couners );
            perfMonitorFormPresenterBindingSource.DataSource = Presenter;
        }
        //public Dictionary<sbyte, IOpHandler> OpHandlers { get; private set; }

        public WebSocketServiceProvider(IAppServer appServer)
        {
            //BinaryDataParser = appServer.GetService<IBinaryDataParser>();
            StringParser = appServer.GetService<IStringParser>();
            //OpHandlers = (new IOpHandler[] {
            //                new TextHandler(this), new BinaryHandler(this),
            //                new PingHandler(this), new PongHandler(this),
            //                new CloseHandler(this) })
            //             .ToDictionary(h => h.OpCode);
            m_AppServer = appServer;
        }
        public BuildModule(IAppServer appServer)
            : base("/builds")
        {
            _appServer = appServer;

            Post["/start"] = parameters =>
            {
                _appServer.BuildAgent.StartNewBuild(
                    Request.ToKeyValues().Select(kv => new BuildParameter(kv.Key, kv.Value)));

                return HttpStatusCode.OK;
            };
        }
        public TcpSocketServerBase(IAppServer appServer, ListenerInfo[] listeners)
            : base(appServer, listeners)
        {
            var config = appServer.Config;

            uint dummy = 0;
            m_KeepAliveOptionValues = new byte[Marshal.SizeOf(dummy) * 3];
            //whether enable KeepAlive
            BitConverter.GetBytes((uint)1).CopyTo(m_KeepAliveOptionValues, 0);
            //how long will start first keep alive
            BitConverter.GetBytes((uint)(config.KeepAliveTime * 1000)).CopyTo(m_KeepAliveOptionValues, Marshal.SizeOf(dummy));
            //keep alive interval
            BitConverter.GetBytes((uint)(config.KeepAliveInterval * 1000)).CopyTo(m_KeepAliveOptionValues, Marshal.SizeOf(dummy) * 2);

            m_SendTimeOut = config.SendTimeOut;
            m_ReceiveBufferSize = config.ReceiveBufferSize;
            m_SendBufferSize = config.SendBufferSize;
        }
        /// <summary>
        /// Gets the script sources.
        /// </summary>
        /// <param name="rootConfig">The root config.</param>
        /// <param name="appServer">The app server.</param>
        /// <returns></returns>
        protected override IEnumerable<IScriptSource> GetScriptSources(IRootConfig rootConfig, IAppServer appServer)
        {
            var sources = new List<IScriptSource>();

            string commandDir = string.Empty;
            string serverCommandDir = string.Empty;

            var commandDirSearchOption = SearchOption.TopDirectoryOnly;

            if (rootConfig.Isolation == IsolationMode.None)
            {
                commandDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Command");
                serverCommandDir = Path.Combine(commandDir, appServer.Name);
            }
            else
            {
                commandDirSearchOption = SearchOption.AllDirectories;
                commandDir = Path.Combine(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName, "Command");
                serverCommandDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Command");
            }

            List<string> commandFiles = new List<string>();

            if (Directory.Exists(commandDir))
                commandFiles.AddRange(GetCommandFiles(commandDir, commandDirSearchOption));

            if (Directory.Exists(serverCommandDir))
                commandFiles.AddRange(GetCommandFiles(serverCommandDir, SearchOption.AllDirectories));

            if (!commandFiles.Any())
            {
                return sources;
            }

            foreach (var file in commandFiles)
            {
                sources.Add(new FileScriptSource(file));
            }

            return sources;
        }
        public bool Initialize(string name, IAppServer appServer)
        {
            Name = name;

            var ipRange = appServer.Config.Options.GetValue("ipRange");

            string[] ipRangeArray;

            if (string.IsNullOrEmpty(ipRange)
                || (ipRangeArray = ipRange.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)).Length <= 0)
            {
                throw new ArgumentException("The ipRange doesn't exist in configuration!");
            }

            m_IpRanges = new Tuple<long, long>[ipRangeArray.Length];

            for (int i = 0; i < ipRangeArray.Length; i++)
            {
                var range = ipRangeArray[i];
                m_IpRanges[i] = GenerateIpRange(range);
            }

            return true;
        }
 public AsyncSocketServer(IAppServer appServer, ListenerInfo[] listeners)
     : base(appServer, listeners)
 {
 }
 public WebSocketHeaderReader(IAppServer server)
     : base(server)
 {
 }
 public PayloadControlForm( IAppServer server )
 {
     InitializeComponent();
     IPayloadControlFormPresenter presenter = new PayloadControlFormPresenter( server );
     payloadControlFormPresenterBindingSource.DataSource = presenter;
 }
 public WebSocketHeaderReader(IAppServer server)
     : base(server)
 {
     m_SearchState = new SearchMarkState<byte>(m_HeaderTerminator);
 }
 public bool Initialize(string name, IAppServer appServer)
 {
     Name = name;
     AppServer = appServer;
     return true;
 }
 public MainFormPresenter( IAppServer server, PerfMonitorForm monitorForm, PayloadControlForm payloadForm )
 {
     _server = server;
     _monitorForm = monitorForm;
     _payloadForm = payloadForm;
 }
Exemple #14
0
 internal static LocalDataStoreSlot SetCurrentServer(IAppServer server)
 {
     var slot = Thread.GetNamedDataSlot(m_ServerDataSlotName);
     Thread.SetData(slot, server);
     return slot;
 }
 public PayloadControlFormPresenter( IAppServer server )
 {
     _server = server;
 }