Пример #1
0
        public async Task EditServerSettingsInDatabase()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await Task.Delay(50);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();

            Command command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            getResponse.ServerSettings[0].GameName = "Edited!";
            command = new Command("EditServerSettings", getResponse.ServerSettings[0]);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_EDITED);
        }
Пример #2
0
    void GlobalInit()
    {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
#if UNITY_STANDALONE_WIN
        DllTest.GetProcessWnd();
#endif
        try
        {
            //全局的初始化
            LogMgr.GlobalInit();
            Utility.GlobalInit();
            RuntimeInfo.GlobalInit();
            SDKMgr.Instance.GlobalPreInit();

            Resolution.GlobalInit();
            StringTable.GlobalInit();
            SceneObjMgr.Instance.GlobalInit();
            ResManager.Instance.GlobalInit();   //Res需要在SDKMgr的前面。
            //ReportException.Instance.GlobalInit();
            SDKMgr.Instance.GlobalInit();
            ServerSetting.GlobalInit();

            GlobalUpdate.GlobalInit();
            NetCmdMapping.GlobalInit();
            LogicManager.Instance.GlobalInit();
            UICamera.onPress = OnPress;
            Utility.GlobalInit();
        }
        catch (System.Exception e)
        {
            ReportException.Instance.AddException(e.ToString());
        }
    }
Пример #3
0
        public static void Register(string programNamespace)
        {
            ServicePointManager.SetTcpKeepAlive(true, 5 * 60 * 1000, 5 * 60 * 1000); // 设置系统socket如果5分钟没有交互,需要发送心跳包,进行保活

            //初始化线程池最小大小 为 1000
            ThreadPool.GetMinThreads(out var wt, out var ct);
            if (wt < 1000 || ct < 1000)
            {
                ThreadPool.SetMinThreads(Math.Max(wt, 1000), Math.Max(ct, 1000));
            }
            var    rpcServer = ServerSetting.GetRpcServer();
            string assPath   = string.IsNullOrEmpty(programNamespace)
                ? rpcServer.AssemblyPath
                : programNamespace.EndsWith(".dll")
                    ? programNamespace
                    : programNamespace + ".dll";

            if (rpcServer != null)
            {
                GrantServerConfig s = new GrantServerConfig()
                {
                    Port         = rpcServer.Port,
                    ServerType   = rpcServer.ServerType,
                    AssemblyPath = assPath,
                    Pool         = rpcServer.Pool,
                    Ip           = rpcServer.Ip,
                    TimeOut      = rpcServer.TimeOut,
                    Enable       = rpcServer.Enable,
                    PortList     = rpcServer.PortList,
                };
                Register(s);
            }
            logger.LogInformation($"ThreadPool.GetMinThreads: worker-{Math.Max(wt, 1000)}; io-{Math.Max(ct, 1000)}");
        }
Пример #4
0
        /// <summary>
        /// 构造
        /// </summary>
        public LogStat()
        {
            CreatedDate = DateTime.Now;
            var rpc = ServerSetting.GetRpcServer();

            this.ComputerIp = $"{rpc.Ip}:{rpc.Port}";
        }
Пример #5
0
        public static IWebHost BuildWebHost(string[] args)
        {
            // 要做weapi就需要指定服务名,因为根据服务名才能知道相关配置,这个是因为webapi在启动前首先要指定端口
            if (args != null && args.Length > 0)
            {
                SuperGMS.HttpProxy.SuperHttpProxy.HttpProxyName = args[0];
            }
            var server = ServerSetting.GetRpcServer(SuperHttpProxy.HttpProxyName);
            var host   = WebHost.CreateDefaultBuilder()
                         .UseUrls(
                $"http://*:{server.Port}/")
                         .UseStartup <Startup>().UseKestrel(options => {
                //请求内容长度限制(单位B)
                int maxLength = 0;
                var maxBody   = ServerSetting.Config.ConstKeyValue.Items.FirstOrDefault(i => i.Key == "MaxHttpBody")?.Value;
                if (!string.IsNullOrEmpty(maxBody))
                {
                    int.TryParse(maxBody, out maxLength);
                }
                if (maxLength < 4194304)
                {
                    maxLength = 4194304;                          // 最小4M
                }
                if (maxLength > 104857600)
                {
                    maxLength = 104857600;                            // 最大100M
                }
                options.Limits.MaxRequestBodySize = maxLength;
                options.AllowSynchronousIO        = true;
            }).Build();

            return(host);
        }
Пример #6
0
        /// <summary>
        /// Establishes connection to the database server
        /// </summary>
        public Server Connect()
        {
            try
            {
                oServerSetting = oSettingBL.GetServerSetting();

                if (oServerSetting != null)
                {
                    ServerConnection _serverConnection = new ServerConnection(oServerSetting.Name);

                    _serverConnection.LoginSecure = true;
                    _serverConnection.Login       = oServerSetting.UserName;
                    _serverConnection.Password    = oServerSetting.Password;

                    return(new Server(_serverConnection));
                }

                return(null);
            }
            catch (Exception ex)
            {
                return(null);

                throw new InvalidArgumentException("A connection to the database server could not be established\n" + ex.Message);
            }
        }
Пример #7
0
        private static async Task CleanUpServerSettings()
        {
            var request = new QueryRequest
            {
                TableName     = ServerSetting.TableName,
                KeyConditions = new Dictionary <string, Condition>
                {
                    { "TableId", new Condition()
                      {
                          ComparisonOperator = ComparisonOperator.EQ,
                          AttributeValueList = new List <AttributeValue>
                          {
                              new AttributeValue {
                                  N = TABLE_ID.ToString()
                              }
                          }
                      } }
                },
                //AttributesToGet = new List<string> { "user_id" }
            };
            var response = await AmazonDynamoDBFactory.Client.QueryAsync(request);

            foreach (var item in response.Items)
            {
                ServerSetting serverSetting = new ServerSetting()
                {
                    TableId = TABLE_ID,
                    Id      = Convert.ToInt32(item["Id"].N)
                };
                await AmazonDynamoDBFactory.Context.DeleteAsync(serverSetting);
            }
        }
Пример #8
0
        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.

            m_MediaResourceManager.Clear();
            m_MediaResourceManager.LoadHandlers();

            ConfigurationManager.RefreshSection("appSettings");
            ConfigurationManager.RefreshSection("media-servers");

            CommonLog.Info("=== Media Server is starting ===");

            var appSettings = ConfigurationManager.AppSettings;

            string allAvailableChannels = "";

            if (appSettings.AllKeys.Contains("AvailableChannels"))
            {
                allAvailableChannels = appSettings["AvailableChannels"];
            }
            if (allAvailableChannels.Length > 0)
            {
                m_MediaResourceManager.SetAvailableChannelNames(allAvailableChannels);
            }

            string remoteValidationURL = "";

            if (appSettings.AllKeys.Contains("RemoteValidationURL"))
            {
                remoteValidationURL = appSettings["RemoteValidationURL"];
            }

            var mediaServerSettings = (NameValueCollection)ConfigurationManager.GetSection("media-servers");
            var allKeys             = mediaServerSettings.AllKeys;

            foreach (var key in allKeys)
            {
                string                json        = mediaServerSettings[key];
                ServerSetting         setting     = JsonConvert.DeserializeObject <ServerSetting>(json);
                HttpSourceMediaServer mediaServer = new HttpSourceMediaServer(key, m_MediaResourceManager, CommonLog.GetLogger(),
                                                                              setting.InputIp, setting.InputPort, setting.OutputIp, setting.OutputPort, setting.InputWhitelist, setting.CertFile, setting.CertKey);
                mediaServer.InputQueueSize         = setting.InputQueueSize;
                mediaServer.InputBufferSize        = setting.InputBufferSize;
                mediaServer.OutputQueueSize        = setting.OutputQueueSize;
                mediaServer.OutputBufferSize       = setting.OutputBufferSize;
                mediaServer.OutputSocketBufferSize = setting.OutputSocketBufferSize;
                mediaServer.SetClientValidator(new MediaClientValidator(CommonLog.GetLogger(), remoteValidationURL));
            }

            var servers = m_MediaResourceManager.GetServerList();

            foreach (var item in servers)
            {
                if (item.Start())
                {
                    CommonLog.Info("Media Server is working on port " + item.InputPort
                                   + " (input) and port " + item.OutputPort + " (output) ... ");
                }
            }
        }
Пример #9
0
        public async Task AddAlreadyExistingServerSettingsInDatabase()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await Task.Delay(50);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            byte[]        buffer         = new byte[1024 * 4];
            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();

            Command command    = new Command("AddServerSetting", serverSettings);
            string  sendString = command.ToJson();

            byte[] sendBytes = System.Text.UTF8Encoding.UTF8.GetBytes(sendString);
            await webSocket.SendAsync(new ArraySegment <byte>(sendBytes, 0, sendBytes.Length), WebSocketMessageType.Text, true, CancellationToken.None);

            await webSocketHandler.ExtractCompleteMessage(buffer, 60);

            ModifySettingsResponse response = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(response, ModifySettingsResult.SETTING_ADDED);

            await webSocket.SendAsync(new ArraySegment <byte>(sendBytes, 0, sendBytes.Length), WebSocketMessageType.Text, true, CancellationToken.None);

            await webSocketHandler.ExtractCompleteMessage(buffer, 60);

            response = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(response, ModifySettingsResult.GAME_SEED_ALREADY_EXISTS);
        }
        private void remove_ToolStripButton_Click(object sender, EventArgs e)
        {
            GridViewRowInfo row = GetFirstSelectedRow();

            if (row != null)
            {
                ServerSetting setting = row.DataBoundItem as ServerSetting;

                DialogResult dialogResult = MessageBox.Show
                                            (
                    $"Removing setting '{setting.Name}'.  Do you want to continue?",
                    "Delete Setting",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question

                                            );

                if (dialogResult == DialogResult.Yes)
                {
                    using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
                    {
                        FrameworkServer server = context.FrameworkServers.First(n => n.FrameworkServerId == setting.FrameworkServerId);
                        server.ServerSettings.Remove(server.ServerSettings.First(n => n.Name == setting.Name));
                        context.SaveChanges();

                        BindSettingsToGrid(context);
                    }
                }
            }
        }
Пример #11
0
        public async Task AlreadyExistingSeed_Add()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await Task.Delay(50);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();

            Command command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            serverSettings = TestHelper.GenerateNewServerSetting();
            serverSettings.WorldGenSeed = getResponse.ServerSettings[0].WorldGenSeed;
            command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.GAME_SEED_ALREADY_EXISTS);
        }
Пример #12
0
        public static MainServer StartNew(ServerSetting setting)
        {
            var sev = new MainServer(setting);
            var ipa = string.IsNullOrEmpty(setting.host) ? IPAddress.Any : IPAddress.Parse(setting.host);

            sev.Start(new IPEndPoint(ipa, setting.port));
            return(sev);
        }
Пример #13
0
        public LogRequest()
        {
            CreatedDate = DateTime.Now;
            var rpc = ServerSetting.GetRpcServer();

            this.ComputerIp  = $"{rpc.Ip}:{rpc.Port}";
            this.CreatedDate = DateTime.Now;
            this.ServiceName = ServerSetting.AppName;
        }
Пример #14
0
        public static void Main(string[] args)
        {
            var user     = new UserAuthentication();
            var settings = new ServerSetting();
            var service  = new MimeService(settings, user);

            service.Send(Dummy.Mail());
            Console.WriteLine("Email send to: " + Dummy.Mail().Recievers.FirstOrDefault());
        }
Пример #15
0
 /// <summary>
 /// 构造
 /// </summary>
 /// <param name="context"></param>
 public Qt2Api(UserContext context)
 {
     _token   = context?.Token;
     _baseUrl = ServerSetting.GetConstValue("HttpProxy")?.Value;
     if (string.IsNullOrEmpty(_baseUrl))
     {
         logger.LogError("服务没有配置HttpProxy常量,默认设置为开发版api网关地址!");
         _baseUrl = "http://192.168.100.121/api/";
     }
 }
Пример #16
0
 public TRAY_FORM()
 {
     _shutdown      = false;
     _userSession   = new UserSession();
     _deviceSetting = new DeviceSetting(_userSession);
     _serverSetting = new ServerSetting(_userSession);
     _employees     = new Employees(_deviceSetting, _userSession);
     _companies     = new Companies(_userSession);
     InitializeComponent();
 }
Пример #17
0
 public ServerForm()
 {
     InitializeComponent();
     setting = new ServerSetting()
     {
         LocalPort = int.Parse(textBox_port.Text)
     };
     InitializeServer();
     timer1.Start();
 }
        private void addAccount_Click(object sender, RoutedEventArgs e)
        {
            SalesforceApplication.ServerConfiguration.SetSelectedServer(listboxServers.SelectedIndex);
            SalesforceApplication.ResetClientManager();
            ServerSetting    server  = listboxServers.SelectedItem as ServerSetting;
            SalesforceConfig config  = SalesforceApplication.ServerConfiguration;
            LoginOptions     options = new LoginOptions(server.ServerHost, config.ClientId, config.CallbackUrl, config.Scopes);

            StartLoginFlow(options);
        }
Пример #19
0
        /// <summary>
        /// 这里需要定时清理不用的连接
        /// </summary>
        private static void Clear()
        {
            while (true)
            {
                try
                {
                    string[] key = ConnectionPools.Keys.ToArray();
                    if (key.Length > 0)
                    {
                        // 为了保证性能,随机检查,不做全量遍历
                        Random random = new Random(DateTime.Now.Millisecond);
                        int    idx    = random.Next(0, key.Length);
                        lock (root)
                        {
                            if (ConnectionPools.ContainsKey(key[idx]))
                            {
                                var lst = ConnectionPools[key[idx]];

                                // 连接池里面里连接大于1的时候才会清理,防止清空了就起不到连接池的作用了
                                if (lst.Count > 1)
                                {
                                    // 2分钟不被使用,就清理掉
                                    var timeOut = lst.Where(a => DateTime.Now.Subtract(a.V1).TotalSeconds > 60 * 2)
                                                  .ToArray();
                                    foreach (var item in timeOut)
                                    {
                                        // 始终保持有1个,超时也不能清空
                                        if (lst.Count > 1)
                                        {
                                            // 把超时的移除掉 , 释放掉连接
                                            lst.Remove(item);
                                            item.V2.Close();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "ClientConnectionManager.Clear.Error");
                }

                var rpcSocketIntervalTime = ServerSetting.GetConstValue("RpcSocketRecycleIntervalMin")?.Value;
                int timeSpan = 0;
                int.TryParse(rpcSocketIntervalTime ?? "3", out timeSpan);
                if (timeSpan < 1)
                {
                    timeSpan = 3;
                }
                // 3分钟检查一次,这里只是为了防止连接长期防止缓存池,检查频度不要求太高(2分钟过期+3分钟检查间隔其实就是5分钟)
                Thread.Sleep(timeSpan * 60 * 1000);
            }
        }
Пример #20
0
 public static void Register()
 {
     ServerSetting.Initlize(SuperGMS.HttpProxy.SuperHttpProxy.HttpProxyName, 0);
     string[] server = GetAllServer();
     Reg(server);
     ServerSetting.RegisterRouter(SuperGMS.HttpProxy.SuperHttpProxy.HttpProxyName,
                                  ServerSetting.Config.ServerConfig.RpcService.Ip,
                                  ServerSetting.Config.ServerConfig.RpcService.Port,
                                  ServerSetting.Config.ServerConfig.RpcService.Enable,
                                  ServerSetting.Config.ServerConfig.RpcService.TimeOut);
 }
        public async Task StartAndShutdownServerWithGameMod()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();

            serverSettings.GameMod = "FastProgress";
            Command command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            bool foundServerSetting = false;

            foreach (var item in getResponse.ServerSettings)
            {
                if (serverSettings.WorldGenSeed == item.WorldGenSeed)
                {
                    serverSettings     = item;
                    foundServerSetting = true;
                }
            }
            if (!foundServerSetting)
            {
                Assert.Fail("Added ServerSettingsId not found in response");
            }

            command = new Command("StartServer", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            StartServerResponse startResponse = JsonConvert.DeserializeObject <StartServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(startResponse, StartServerResult.SERVER_STARTED);

            command = new Command("StopServer", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            StopServerResponse stopResponse = JsonConvert.DeserializeObject <StopServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(stopResponse, StopServerResult.SERVER_STOPPED);
        }
        private DialogResult EditSetting(ServerSetting setting, bool addingNew)
        {
            DialogResult result = DialogResult.None;

            using (ServerSettingsEditForm form = new ServerSettingsEditForm(setting, addingNew))
            {
                result = form.ShowDialog();
            }

            return(result);
        }
Пример #23
0
        /// <summary>
        /// 根据微服务的名字拉取配置地址
        /// </summary>
        /// <param name="appName">appName</param>
        public static void Register(string appName)
        {
            var rpcClients = ServerSetting.GetAppClient(appName, updateAppClinet);

            if (rpcClients == null || rpcClients.RpcClients == null)
            {
                return;
            }

            Parser(rpcClients.RpcClients);
        }
Пример #24
0
        public CommonResponse Test()
        {
            ServerSetting setting = ConfigurationTool.GetAppSettings <ServerSetting>("OmniCoin.MiningPool.API.conf.json", "ServerSetting");

            if (setting.IsTestNet)
            {
                return(OK("Test"));
            }
            else
            {
                return(OK("Main"));
            }
        }
 private void StartLoginFlow(ServerSetting server)
 {
     if (server != null)
     {
         VisualStateManager.GoToState(this, LoggingUserInViewState, true);
         SDKManager.ResetClientManager();
         SalesforceConfig config = SDKManager.ServerConfiguration;
         var options             = new LoginOptions(server.ServerHost, config.ClientId, config.CallbackUrl, config.Scopes);
         SalesforceConfig.LoginOptions = new LoginOptions(server.ServerHost, config.ClientId, config.CallbackUrl,
                                                          config.Scopes);
         DoAuthFlow(options);
     }
 }
Пример #26
0
        public ServerSettingPage()
        {
            this.InitializeComponent();

            // x86/x64でもリモート環境と同じWindowサイズで起動する
            ApplicationView.PreferredLaunchViewSize = new Size {
                Width = 800, Height = 480
            };
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            p           = new ServerSetting(this);
            DataContext = p;
        }
Пример #27
0
        private async Task MainLoop()
        {
            serverCore = new ServerCore <ServerLoop>(Logger);
            //グループを作成
            var group = Group.Create();

            ClientGroups.Add(group);

            serverCore.ConnectionReset = (x) =>
            {
                Logger.LogInformation($"{x.Name}さんが切断されました");
            };

            Console.WriteLine("MainLoop Start.");
            //すべてのIPで接続を受け付ける
            IPAddress  ipAddress     = IPAddress.Any;
            IPEndPoint localEndPoint = new IPEndPoint(ipAddress, PortNumber);
            var        serverSetting = new ServerSetting {
                UseSSL = false
            };

            serverSetting.LoadCertificateFile("test-cert.pfx", "testcert");

            //Filter
            var authtificationFilter = new LocalAuthentificationFilter();

            serverCore.SocketyFilters.Add(authtificationFilter);


            serverCore.Start(localEndPoint: localEndPoint, _stoppingCts: _stoppingCts, parent: this, _serverSetting: serverSetting);

            int cnt = 0;

            while (!_stoppingCts.IsCancellationRequested)
            {
                if (cnt++ == 5)
                {
                    try
                    {
                        serverCore.BroadCastNoReturn("Push", null);
                        Logger.LogInformation("Push");
                    }
                    catch (Exception ex)
                    {
                        Logger.LogInformation(ex.ToString());
                    }
                    cnt = 0;
                }
                Thread.Sleep(1000);
            }
        }
        /// <summary>
        /// Creates a new instance of ServerSettingsEditForm.
        /// </summary>
        /// <param name="setting"></param>
        public ServerSettingsEditForm(ServerSetting setting, bool addingNew)
        {
            InitializeComponent();

            UserInterfaceStyler.Configure(this, FormStyle.FixedDialog);

            _setting   = setting;
            _addingNew = addingNew;

            fieldValidator.RequireValue(name_TextBox, name_Label);
            fieldValidator.RequireValue(value_TextBox, value_Label);
            fieldValidator.SetIconAlignment(name_TextBox, ErrorIconAlignment.MiddleLeft);
            fieldValidator.SetIconAlignment(value_TextBox, ErrorIconAlignment.MiddleLeft);
        }
        private void addCustomHostBtn_Click(object sender, RoutedEventArgs e)
        {
            string        hname    = hostName.Text;
            string        haddress = hostAddress.Text;
            ServerSetting server   = new ServerSetting()
            {
                ServerHost = haddress,
                ServerName = hname
            };

            SalesforceApplication.ServerConfiguration.AddServer(server);

            ServerFlyout.ShowAt(applicationTitle);
        }
Пример #30
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            CommonLog.SetGuiControl(this, mmLog);

            RemoteCaller.HttpConnectionLimit = 1000;

            var appSettings = ConfigurationManager.AppSettings;

            var allKeys = appSettings.AllKeys;

            foreach (var key in allKeys)
            {
                if (key == "InternalServer")
                {
                    m_InternalSetting = JsonConvert.DeserializeObject <ServerSetting>(appSettings[key]);
                }
                if (key == "PublicServer")
                {
                    m_PublicSetting = JsonConvert.DeserializeObject <ServerSetting>(appSettings[key]);
                }

                if (key == "NodeName")
                {
                    m_NodeName = appSettings[key];
                }
                if (key == "GroupName")
                {
                    m_GroupName = appSettings[key];
                }
                if (key == "ServerInfoStorageName")
                {
                    m_StorageName = appSettings[key];
                }

                if (key == "Services")
                {
                    var fileNames = appSettings[key].Split(',');
                    m_ServiceFileNames.Clear();
                    m_ServiceFileNames.AddRange(fileNames);
                }
            }

            if (m_ServerNode == null)
            {
                m_ServerNode = new ServerNode(m_NodeName, m_GroupName, CommonLog.GetLogger());
                m_ServerNode.SetServerInfoStorage(m_StorageName);
                m_ServerNode.ResetLocalServiceFiles(m_ServiceFileNames);
            }
        }
        public void RegionLoaded(IScene scene)
        {
            IServerSettings serverSettings = scene.RequestModuleInterface<IServerSettings>();
            ServerSetting gravitySetting = new ServerSetting
                                               {
                                                   Name = "Gravity",
                                                   Comment = "The forces of gravity that are on this sim",
                                                   Type = "Color4" //All arrays are color4
                                               };
            gravitySetting.OnGetSetting += delegate()
                                               {
                                                   return
                                                       string.Format(
                                                           "<array><real>{0}</real><real>{1}</real><real>{2}</real><real>1.0</real></array>",
                                                           scene.PhysicsScene.GetGravityForce()[0],
                                                           scene.PhysicsScene.GetGravityForce()[1],
                                                           scene.PhysicsScene.GetGravityForce()[2]);
                                               };
            gravitySetting.OnUpdatedSetting += delegate(string value) { };

            serverSettings.RegisterSetting(gravitySetting);
        }
Пример #32
0
        public ServerViewModel()
        {
            StartServerCommand = new RelayCommand(async()=>
            {
                await StartServerAsync();
            });

            StopServerCommand = new RelayCommand(()=>
            {
                if(client != null)
                {
                    client.Close();
                }
                if (listner != null)
                {
                    listner.Stop();
                    listner = null;
                }
            });

            LogList = new ObservableCollection<string>();
            Setting = new ServerSetting();
        }
Пример #33
0
 public void UnregisterSetting(ServerSetting setting)
 {
     m_settings.RemoveAll(s => s.Name == setting.Name);
 }
Пример #34
0
 public void RegisterSetting(ServerSetting setting)
 {
     m_settings.Add(setting);
 }