private void SetupSync() { // Set up client ILog clientLogger = LogManager.GetLogger("Client"); log4net.Config.XmlConfigurator.Configure(clientLogger.Logger.Repository); ClientContainer.Register <ILog>(clientLogger); ClientContainer.Register <IRepository <TestItem, Guid> >(ClientRepository); ClientContainer.Register <ISyncResult <TestItem, Guid>, SyncResult <TestItem, Guid> >(); ClientContainer.Register <IReplica>(new Replica("Client")); // Set up server ILog serverLogger = LogManager.GetLogger("Server"); log4net.Config.XmlConfigurator.Configure(serverLogger.Logger.Repository); ServerContainer.Register <ILog>(clientLogger); ServerContainer.Register <IRepository <TestItem, Guid> >(ServerRepository); ServerContainer.Register <ISyncResult <TestItem, Guid>, SyncResult <TestItem, Guid> >(); ServerContainer.Register <IReplica>(ServerReplica); ServerRepository.Insert(TestItemR0); // Start with an item on the server // Used for both client and server Container.Register <ISyncConflictResolver <TestItem, Guid>, TestItemConflictResolver>(); // Just pass the sync requests directly between the server and client // Ordinarily these would by serialized and sent over a wire, but the // TestSyncRequestSender, just passes the object directly. ClientContainer.Register <ISyncRequestSender <TestItem, Guid> >(new TestSyncRequestSender <TestItem, Guid>(ServerSendingSynchronizer)); ClientSendingSynchronizer.BeginSync(ServerReplica); }
/// <summary> /// Stops the server. /// </summary> /// <param name="serverId">The server id.</param> /// <returns>True, if the server stopped, otherwise False.</returns> public bool StopServer(long serverId) { DoDisposeCheck(); bool result = false; mLockForServers.EnterUpgradeableReadLock(); try { if (mServers.ContainsKey(serverId)) { mLockForServers.EnterWriteLock(); try { if (mServers.ContainsKey(serverId)) { result = true; ServerContainer sc = mServers[serverId]; sc.Listener.Stop(); mServers.Remove(serverId); } } finally { mLockForServers.ExitWriteLock(); } } } finally { mLockForServers.ExitUpgradeableReadLock(); } return(result); }
/// <summary> /// This is the original method, to be deleted... or not. /// </summary> /// <param name="user"></param> /// <param name="usersDistributions"></param> private void GetUsersDistributions(string userEmail, Dictionary <string, EmbeddedDirective> usersDistributions) { Dictionary <string, DistributionType> subscribedUsers = new Dictionary <string, DistributionType>(); subscribedUsers.Add(userEmail, DistributionType.myDistribution); this.getSubscribedUsers(userEmail, subscribedUsers); ServerContainer container = this._server.GetContainer(ObjectType.EmbeddedDirectivesV2); foreach (PropertyList list in container.Items(null)) { EntryID yid; list.Get(PropID.EntryID, out yid); EmbeddedDirective directive = (EmbeddedDirective)container.Open(yid); string key = directive.Source.Get(PropID.Description); string str2 = directive.Source.Get(PropID.ApplicationTag); if (str2 == userEmail) { usersDistributions.Add(key, directive); } else { DistributionType type; if (subscribedUsers.TryGetValue(str2, out type) && (type == DistributionType.publicDistribution)) { usersDistributions.Add(key, directive); } } } }
public void Listen() { if (!ServerContainer.IsTCPOnline) { ServerContainer.Start(); } }
private Task ClientOnReactionAdded(Cacheable <IUserMessage, ulong> cacheable, ISocketMessageChannel socketMessageChannel, SocketReaction arg3) { var server = ServerContainer.GetServerById((long)((IGuildChannel)arg3.Channel).GuildId); if (arg3.UserId != _client.CurrentUser.Id && server != null && arg3.MessageId == (ulong)server.Options.RoleEmoteMessageId) { foreach (var roleEmote in server.Options.RoleEmotes) { if (roleEmote.Emote.Equals((long)((Emote)arg3.Emote).Id)) { try { var role = savedRoles.FirstOrDefault(x => x.Id == (ulong)roleEmote.DiscordRole); if (role == null) { role = ((IGuildChannel)arg3.Channel).Guild.GetRole((ulong)roleEmote.DiscordRole); savedRoles.Add(role); } ((IGuildUser)arg3.User.Value).AddRoleAsync(role); //arg3.Channel.SendMessageAsync($"Added {role.Name} to {arg3.User.Value.Username}"); } catch { } } } } return(Task.CompletedTask); }
public async void InitPowerPit() { if (!InGameFlop) { InGameFlop = true; await Task.Run(() => { //Wait for the internal Timer to reach 500 (5 seconds). while (_server.InternalTimer <= 500) { } var spawnPointCount = _server.ServerMemory.ReadInt(_server.ServerMemory.BlamCachePointer(0x143c100)); while (spawnPointCount == 0) { spawnPointCount = _server.ServerMemory.ReadInt(_server.ServerMemory.BlamCachePointer(0x143c100)); } var spawnPointReflexOffset = _server.ServerMemory.ReadInt(_server.ServerMemory.BlamCachePointer(0x143c104)); var spawnPointReflexStart = _server.ServerMemory.BlamCachePointer(spawnPointReflexOffset); MainThread.WriteLine(spawnPointCount); List <PointF> aPoints = new List <PointF>(); List <PointF> bPoints = new List <PointF>(); List <PointF> cPoints = new List <PointF>(); List <PointF> dPoints = new List <PointF>(); ServerContainer.FillPoints(ref aPoints, 45, -4.4f, -1.6f, 18.3f, 18.9f); ServerContainer.FillPoints(ref bPoints, 45, -5.0f, -4.46f, 18.3f, 16.4f); ServerContainer.FillPoints(ref cPoints, 45, -4.5f, -1.6f, 15.7f, 16.4f); ServerContainer.FillPoints(ref dPoints, 48, -1.63f, -1f, 16.3f, 18.2f); List <PointF> points = new List <PointF>(); points.AddRange(aPoints); points.AddRange(bPoints); points.AddRange(cPoints); points.AddRange(dPoints); for (var i = 0; i < spawnPointCount; i++) { var itemOffset = i * 52; var itemAddress = spawnPointReflexStart + itemOffset; _server.ServerMemory.WriteFloat(itemAddress, points[i].X); _server.ServerMemory.WriteFloat(itemAddress + 4, points[i].Y); _server.ServerMemory.WriteFloat(itemAddress + 8, 20f); } for (int i = 0; i < 16; i++) { var playerObjectIndex = _server.ServerMemory.ReadUShort(0x300026F0 + (i * 0x204)); if (playerObjectIndex != ushort.MaxValue) { int playerTableIndexOffset = playerObjectIndex * 12; int playerTableObjectPointerAddress = 0x3003CAE8 + playerTableIndexOffset + 8; int playerTableObjectAddress = _server.ServerMemory.ReadInt(playerTableObjectPointerAddress); _server.ServerMemory.WriteMemory(false, playerTableObjectAddress + 0x208, new byte[] { 0x01, 0xFE, 0xFE, 0xFF }); } } }); } }
private void BindServerList() { ActiveServerList = ServerManager.GetActiveServerList(); ServerContainer.DataSource = ActiveServerList; ServerContainer.DataBind(); }
public void Initialize() { EnableRunning = true; PumpServer.OnNewQuote += WhenNewQuote; CopyServer.OnNewTrade += WhenNewTrade; if (_quoteTimer == null) { _quoteTimer = new Timer(10000); _quoteTimer.Elapsed += SaveQuoteProc; SaveQuoteProc(_quoteTimer, null); } if (_tradeThread == null) { _tradeThread = new System.Threading.Thread( () => { while (Utils.SignalWait(ref EnableRunning, _tradeSignal)) { TradeInfoEventArgs item = null; _queTrades.TryDequeue(out item); PushTrade(item); } foreach (var item in _queTrades.ToArray()) { PushTrade(item); } ServerContainer.FinishStop(); }); _tradeThread.IsBackground = true; _tradeThread.Start(); } var logger = Utils.CommonLog; logger.Info("订单与报价同步服务已经启动"); }
public LocalizacaoRickControllerBase(IConfiguration configuration) { _server = new ServerContainer(); _server.ConnectionString = configuration.GetConnectionString(configuration["BancoDados"].Trim()); configuration.Bind(_server.Configuration); }
public Form1() { InitializeComponent(); ApplicationStatus.activeServer = null; serverContainer = new ServerContainer(this); addServerForm = new AddServerForm(this); editServerForm = new EditServerForm(this); timer = new Timer(); timer.Interval = pingInterval * 1000; timer.Tick += new EventHandler(timerTick); timer.Start(); downloadMessageWatch = new Stopwatch(); downloadMessageWatch.Start(); serverList.View = View.Details; serverList.MultiSelect = false; int columnWidth = 130; serverList.Columns.Add("Name", columnWidth, HorizontalAlignment.Left); serverList.Columns.Add("Website", columnWidth, HorizontalAlignment.Left); serverList.Columns.Add("Version", columnWidth, HorizontalAlignment.Left); serverList.Columns.Add("Status", columnWidth, HorizontalAlignment.Left); VersionChecker.checkForNewVersion(); }
public void Initialize() { var logger = Utils.CommonLog; logger.Info("MT4订阅服务已经启动"); EnableRunning = true; ServerContainer.ForkServer <CopyServer>(); StartPump(); }
public void Stop() { if (_thTime != null) { _thTime.Abort(); _thTime = null; } ServerContainer.FinishStop(); }
/// <summary> /// Initializes a new instance of the <see cref="TerraGrafPeerUpdateMessage"/> class. /// </summary> /// <param name="senderId">The sender id.</param> /// <param name="serverContainer">The server container.</param> internal TerraGrafPeerUpdateMessage(string senderId, ServerContainer serverContainer) : base(senderId, string.Empty, MessageCodeEnum.TerraGrafPeerUpdate, Interlocked.Increment(ref mGlobalMessageId), MessagePriorityEnum.Normal, MessageTypeEnum.Udp) { if (serverContainer == null) { ThrowHelper.ThrowArgumentNullException("serverContainer"); } this.mServerContainer = serverContainer; }
public ServerConfiguration SpawnDefaultServer() { int port = startingRange + 1; ServerConfiguration result = new ServerConfiguration(); result.port = port; this.defaultServer = new ServerContainer(result); this.log.Write(LogLevel.TRACE, LogType.CONSOLE, "Creating Default ServerContainer on port: " + port); defaultServer.startContainer(); return(result); }
public void Stop() { EnableRunning = false; System.Threading.Thread.Sleep(1000); foreach (var i in _lstRunning) { i.Timer.Stop(); i.FreeMT4(i); } ServerContainer.FinishStop(); }
/// <summary> /// http://[PMS_IP_Address]:32400/library/sections?X-Plex-Token=YourTokenGoesHere /// Retrieves a list of servers tied to your Plex Account /// </summary> /// <param name="authToken">Authentication Token</param> /// <returns></returns> public async Task <List <Server> > GetServers(string authToken) { var apiRequest = new ApiRequestBuilder("https://plex.tv/pms/servers.xml", "", HttpMethod.Get) .AddPlexToken(authToken) .AddRequestHeaders(GetClientIdentifierHeader()) .Build(); ServerContainer serverContainer = await ApiService.InvokeApiAsync <ServerContainer>(apiRequest); return(serverContainer?.Servers); }
/// <summary> /// Builds the server container. /// </summary> /// <returns>ServerContainer</returns> internal ServerContainer BuildServerContainer() { ServerContainer container = new ServerContainer(); container.StateId = mStateId; container.Servers = new AddressEndPoint[mTCPServers.Count]; for (int i = 0; i < mTCPServers.Count; i++) { container.Servers[i] = mTCPServers[i].EndPoint; } return(container); }
public ServerConfiguration SpawnServer() { ServerConfiguration result = new ServerConfiguration(); result.port = actualPort; ServerContainer serverContainer = new ServerContainer(result); this.log.Write(LogLevel.TRACE, LogType.CONSOLE, "Creating ServerContainer on port: " + actualPort); serverContainer.startContainer(); this.serverContainers.Add(serverContainer); actualPort++; return(result); }
public void Stop() { if (ServerContainer.IsTCPOnline) { try { ServerContainer.StopTCPListener(); } catch { ServerContainer = null; Build(Address, Port, KeySize); } } }
/// <summary> /// 测试用控台服务 /// </summary> /// <param name="args"></param> static void Main(string[] args) { //XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4net.config")); //log4net.ILog Log = log4net.LogManager.GetLogger("IBatisNet.DataMapper.SqlMapSession"); //Log.Info("***************应用程序服务器准备启动****************"); try { ServerContainer container = new ServerContainer();//container //IWindsorContainer container2 = new RemotingContainer2(); Console.WriteLine("服务开启,按任意键关闭..."); DBHelper dbhelper = new DBHelper(); dbhelper.UpdateDatabase(); Console.ReadLine(); } catch (Exception er) { Console.WriteLine(er.Message); Console.ReadLine(); } }
public async Task AddEmote(string emoji, string roleName) { var db = new DatabaseContext(); var role = Context.Guild.Roles.FirstOrDefault(x => x.Name.Equals(roleName)); var server = db.Servers.Include(x => x.Options).ThenInclude(x => x.RoleEmotes).FirstOrDefault(x => x.ServerId == (long)Context.Guild.Id); if (role != null && server != null) { var obj = new RoleEmote(); obj.DiscordRole = (long)role.Id; var name = emoji.Replace(":", ""); Console.WriteLine(name); Console.WriteLine(Context.Guild.Emotes.First().Name); var emote = Context.Guild.Emotes.FirstOrDefault(x => name.Contains(x.Id.ToString())); obj.Emote = (long)emote.Id; server.Options.RoleEmotes.Add(obj); db.Servers.Update(server); db.SaveChanges(); IUserMessage message = null; foreach (var textChannel in Context.Guild.GetTextChannelsAsync().Result) { try { message = (IUserMessage)await textChannel.GetMessageAsync( (ulong)server.Options.RoleEmoteMessageId); if (message != null) { break; } } catch { } } if (message != null) { ServerContainer.DeleteCache(); await ReplyAsync($"{emoji} was been added for role " + role.Name); await message.AddReactionAsync(emote); } } }
public ServerAlleyBrawl(ServerContainer baseServer) { _server = baseServer; List <PointF> aPoints = new List <PointF>(); List <PointF> bPoints = new List <PointF>(); //Two Boxes ServerContainer.FillPoints(ref aPoints, 68, 11.49f, 18.89f, 51f, 58f); ServerContainer.FillPoints(ref bPoints, 69, 11.18f, 19.18f, 95.1f, 99.33f); points.AddRange(aPoints); points.AddRange(bPoints); //Main Side // ServerContainer.FillPoints(ref aPoints, 68 + 69, 11.49f, 18.89f, 51f, 99.33f); // points.AddRange(aPoints); //All Sides //ServerContainer.FillPoints(ref aPoints, 68, 11.49f, 18.89f, 51f, 99.33f); //ServerContainer.FillPoints(ref bPoints, 69, -8.8f, 0.4f, 61f, 104f); //points.AddRange(aPoints); //points.AddRange(bPoints); }
/// <summary> /// Gets the configured users. /// </summary> /// <returns>collection of strings</returns> public Collection <string> GetConfiguredUsers() { var result = new Collection <string>(); try { ServerContainer container = this._server.GetContainer(ObjectType.ApplicationData); foreach (PropertyList list in container.Items(null)) { if ((list.Get(PropID.Type) == "USER")) { result.Add(list.Get(PropID.ApplicationTag)); } } } catch (Exception ex) { Logger.LogError("Error", ex); throw; } return(result); }
private void getSubscribedUsers(string userEmail, Dictionary <string, DistributionType> subscribedUsers) { ServerContainer container = this._server.GetContainer(ObjectType.ApplicationData); foreach (PropertyList list in container.Items(null)) { if ((list.Get(PropID.Type) == "USER") && (list.Get(PropID.ApplicationTag) == userEmail)) { PropertySet ps = new PropertySet(); list.Get(PropID.PublicEDUsersList, out ps); DistributionType publicDistribution = DistributionType.publicDistribution; foreach (PropertyList list2 in ps) { string key = list2.Get(PropID.ApplicationTag); if (!subscribedUsers.TryGetValue(key, out publicDistribution)) { subscribedUsers.Add(key, DistributionType.publicDistribution); } } } } }
/// <summary> /// Starts the server. /// </summary> /// <param name="endPoint">The end point.</param> /// <param name="serverStreamFactory">The server stream factory.</param> /// <returns>Identifier of the listener</returns> public long StartServer(AddressEndPoint endPoint, IServerStreamFactory serverStreamFactory) { DoDisposeCheck(); if (endPoint == null) { ThrowHelper.ThrowArgumentNullException("endPoint"); } ITcpListener listener = mNetworkFactory.CreateTcpListener(endPoint); listener.Start(); // ez dobhat kivételt ServerContainer container = new ServerContainer(Interlocked.Increment(ref mServerGlobalId), listener, this, serverStreamFactory); mLockForServers.EnterWriteLock(); try { mServers.Add(container.ServerId, container); container.Initialize(); } catch (Exception ex) { if (LOGGER.IsFatalEnabled) { LOGGER.Fatal(ex.Message, ex); } listener.Stop(); throw; } finally { mLockForServers.ExitWriteLock(); } return(container.ServerId); }
private static bool Boot(string[] args) { Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory; bool help = false; bool sync = false; var p = new OptionSet() { { "sync|s", v => sync = v != null }, { "h|?|help", v => help = v != null }, }; try { List <string> extra = p.Parse(args); if (help) { Console.WriteLine( string.Format("无参数:执行MT4Proxy服务\n" + "s|sync执行当天数据聚合\nh|?|help:显示帮助信息")); return(false); } var logger = Utils.CommonLog; MT4CliWrapper.MT4Wrapper.OnLog += (a) => { logger.Info(a); }; if (Environment.Is64BitProcess) { logger.Warn("警告,在64位环境启动"); } else { logger.Info("启动环境是32位"); } logger.Info("准备启动MT4池"); Poll.StartPoll(); ServerContainer.ForkServer <DockServer>(); ServerContainer.ForkServer <TimeServer>(); if (sync) { ServerContainer.ForkServer <SyncServer>(); var syncer = new SyncServer(); syncer.SyncSummary(); syncer.SyncEquity(); #if TESTENV syncer.SyncMaster(30, 500000, 599999); #else syncer.SyncMaster(30, 851000, 859999); syncer.SyncMaster(360, 850001, 850999, "contest_master", 100, new Func <int, double>((mt4) => { using (var api = Poll.New()) { var equity = 0.0; var balance = 0.0; var free = 0.0; api.GetEquity(mt4, ref equity, ref free, ref balance); return(balance / 10000); } } )); #endif Poll.StopPoll(); return(false); } ServerContainer.ForkServer <PumpServer>(); logger.Info("准备启动Zmq监听服务"); ServerContainer.ForkServer <ZmqServer>(); logger.Info("初始工作已完成"); return(true); } catch (OptionException e) { Console.Write("参数格式不正确: "); Console.WriteLine(e.Message); Console.WriteLine("请使用 --help 命令获取更多信息."); return(false); } catch (Exception e) { var logger = Utils.CommonLog; logger.Error(string.Format("SyncError:{0}\n{1}", e.Message, e.StackTrace)); } return(false); }
internal RickCore(ServerContainer serverContainer) : base(serverContainer) { }
public ServerDeathRing(ServerContainer baseServer) { _server = baseServer; }
public ServerPowerPit(ServerContainer baseServer) { _server = baseServer; }
public static void DetectServers(bool Inital = false) { var serverProcesses = Process.GetProcessesByName("h2Server"); if (Inital) { MainThread.WriteLine($"Servers Detected:\t{serverProcesses.Length}"); if (serverProcesses.Length > 0) { ExecutionPath = serverProcesses[0].MainModule?.FileName.Replace("\\h2server.exe", "") .Replace("\\H2Server.exe", ""); MainThread.WriteLine($"Server Launch Path:\t{ExecutionPath}"); MainThread.WriteLine($"Server Playlist Folder:\t{PlaylistFolder}"); } } else { for (var i = 0; i < Servers.Count; i++) { if (Servers[i].ServerProcess.HasExited) { if (!Servers[i].AutoRestart) { MainThread.WriteLine($"{Servers[i].FormattedName} has closed detaching.."); Servers[i].KillConsoleProxy(); Servers.RemoveAt(i); } else { MainThread.WriteLine($"{Servers[i].FormattedName} has closed restarting service.."); var Service = new ServiceController(Servers[i].ServiceName); if (Service.Status != ServiceControllerStatus.Stopped) { Service.Stop(); Servers[i].ServerProcess.Kill(); } Service.Start(); Servers[i].KillConsoleProxy(); Servers.RemoveAt(i); } } } } for (var i = 0; i < serverProcesses.Length; i++) { if (!Servers.ServerCollected(serverProcesses[i])) { MainThread.WriteLine($"Attaching To Server..."); var newServer = new ServerContainer(serverProcesses[i]); newServer.Index = i; if (newServer.isLive) { MainThread.WriteLine($"Attached to: {newServer.FormattedName}"); MainThread.WriteLine($"Service Name: {newServer.ServiceName}"); newServer.LaunchConsoleProxy(); Servers.Add(newServer); } else { MainThread.WriteLine( $"Skipping LAN Server: {newServer.FormattedName}"); } } } }
public VariantM(ServerContainer Server) { this.Server = Server; }
public ServerPostGameCarnage(ServerContainer Server) { this.Server_ = Server; this.Variant = new VariantM(Server); }