public void ClickStartServer() { if (ServerInstance.StartRelay(Port)) // We need relay for a lot of rooms. { StopServerButton.SetActive(true); } }
public void PrepareComputeTableStatistics(Context context, TableReference tr, out string connectionString, out string sql) { // Assign a database server to the query // TODO: maybe make this function generic // TODO: check this part to use appropriate server and database var sm = GetSchemaManager(false); var ds = sm.Datasets[tr.DatasetName]; if (ds is GraywulfDataset && !((GraywulfDataset)ds).IsSpecificInstanceRequired) { var gds = (GraywulfDataset)ds; var dd = new DatabaseDefinition(context); dd.Guid = gds.DatabaseDefinition.Guid; dd.Load(); // Get a server from the scheduler var si = new ServerInstance(Context); si.Guid = Scheduler.GetNextServerInstance(new Guid[] { dd.Guid }, StatDatabaseVersionName, null); si.Load(); connectionString = si.GetConnectionString().ConnectionString; SubstituteDatabaseName(tr, si.Guid, StatDatabaseVersionName); tr.DatabaseObject = null; } else { // Run it on the specific database connectionString = ds.ConnectionString; } // Generate statistics query sql = CodeGenerator.GenerateTableStatisticsQuery(tr); }
/// <summary> /// Initializes this instance. /// Should be called on startup of the application will reset the server if called twice /// </summary> /// <param name="serverId">Server identifier.</param> public static void Init(EntityId serverId) { ServerInstance.Id = serverId; CoflnetSocket.socketServer.Start(); ServerInstance.SetCommandsLive(); Coflnet.ServerController.Instance = Coflnet.Server.ServerController.ServerInstance; }
public static void ClientDisconnectedEventHandler(UdpClient client) { NetWerewolfPlayer player = client.GetPlayer(); player.Status = PlayerStatus.Dead; ServerInstance.Send(2, player.PlayerID); // RemoteClientDisconnected(uint) ServerInstance.Send(5, 0u, $"{player.Name} has fallen..."); try { ConnectedPlayers.Remove(player); GameInfo.Players.Remove(player); } catch { } try { NetWerewolfPlayer nextHost = ConnectedPlayers.First(); if (nextHost != null && !nextHost.IsHost) { nextHost.IsHost = true; nextHost.PlayerClient.Send(199, true); ServerInstance.Send(5, 0, $"{nextHost.Name} is now the game master."); } } catch { } // No players left to be host }
private static ClassDeclarationSyntax LinkNode(ServerInstance instance, out StatementSyntax appStatement) { appStatement = Templates.CallStartNode.Get <StatementSyntax>(instance.Id); //td: var statements = new List <StatementSyntax>(); var only = Templates .StringArray .Get <ArrayCreationExpressionSyntax>() .WithInitializer(StringArrayInitializer(instance.HostedClasses)); statements.Add(Templates .StartNetMQServer .Get <StatementSyntax>( Roslyn.Quoted(instance.Host.Address), Roslyn.Quoted(instance.Parent.Identity), Roslyn.Constant(instance.Threads), only, instance.Id)); var result = Templates .ServerInstance .Get <ClassDeclarationSyntax>(instance.Id, Roslyn.Quoted(instance.Id)); var start = result .DescendantNodes() .OfType <MethodDeclarationSyntax>() .Where(method => method.Identifier.ToString() == "Run" && method.ParameterList.Parameters.Count == 3) .Single(); return(result .ReplaceNode(start, start .AddBodyStatements(statements.ToArray()))); }
/// <summary> /// Dispose /// </summary> public void Dispose() { if (ServerInstance != null) { ServerInstance.Logout(); } }
public void AfterTest(ITest test) { TestContext.WriteLine("Tearing down server and core webdriver"); ServerInstance?.Dispose(); ServerInstance = null; }
private static void WorkWithServer(TcpClient server) { Console.WriteLine("Server found this client"); server.ReceiveTimeout = 1000; server.SendTimeout = 1000; ServerInstance instance = new ServerInstance(); instance.server = server; var stream = server.GetStream(); try { while (true) { if (!server.Connected) { break; } instance.command = new byte[1024]; stream.BeginRead(instance.command, 0, instance.command.Length, OnRead, instance); Thread.Sleep(100); } } catch (Exception e) { Console.WriteLine("Lost connection to the server"); } }
private static void InitApp(ServerInstance app, LexicalExtension <SyntaxToken> extension) { app.Id = extension.Identifier.ToString(); if (string.IsNullOrWhiteSpace(app.Id)) { app.Id = "Default"; } }
public void ConnectToServer() { IServerInstance server = new ServerInstance(serverIp, this); server.ConnectToServer(); server.PingServer(); Assert.IsTrue(server.IsConnected()); }
public void ClickStopServer() { if (ServerInstance.IsActive) { ServerInstance.StopServer(); StopServerButton.SetActive(false); } }
public static void Init(ServerInstance serverInstance) { if (serverInstance.IsConnected()) { IStatusGetter sg = new StatusGetter(serverInstance.server); StatusDELETED = sg.GetStatusDELETED(); StatusCLOSED = sg.GetStatusCLOSED(); } }
/// <summary> /// Helper method which sends system message to main chat room of specified game server. /// </summary> /// <param name="serverName">Name of server which will receive the message.</param> /// <param name="message">The message content.</param> /// <param name="username">If specified, then only this user will see this message.</param> private void sendSystemMessage(String serverName, String message, String username) { ServerInstance server = ServerManager.Instance.GetServer(serverName); if (server != null) { this.Clients.Client(server.SignalRClientId).SystemMessage(message, username); } }
public UpdateProviderGit(ServerInstance serverInstanceInstance, UpdateProviderGitConfiguration configuration, ILogger <UpdateProviderGit> logger, IConfiguration config) { _serverInstance = serverInstanceInstance; _baseUrl = configuration.BaseUrl; _branch = configuration.Branch; _logger = logger; _repoPath = Path.Combine(_serverInstance.InstanceDir, "source"); _configuration = config; }
public void DeterminePartitionCount(Context context, IScheduler scheduler, out int partitionCount, out Guid assignedServerInstanceGuid) { partitionCount = 1; assignedServerInstanceGuid = Guid.Empty; // Single server mode will run on one partition by definition, // Graywulf mode has to look at the registry for available machines switch (ExecutionMode) { case ExecutionMode.SingleServer: InitializeQueryObject(null); break; case ExecutionMode.Graywulf: InitializeQueryObject(context, scheduler); // If query is partitioned, statistics must be gathered if (IsPartitioned) { // Assign a server that will run the statistics queries // Try to find a server that contains all required datasets. This is true right now for // SkyQuery where all databases are mirrored but will have to be updated later // Collect all datasets that are required to answer the query var dss = FindRequiredDatasets(); // Datasets that are mirrored and can be on any server var reqds = (from ds in dss.Values where !ds.IsSpecificInstanceRequired select ds.DatabaseDefinition.Guid).ToArray(); // Datasets that are only available at a specific server instance var spds = (from ds in dss.Values where ds.IsSpecificInstanceRequired && !ds.DatabaseInstance.IsEmpty select ds.DatabaseInstance.Guid).ToArray(); var si = new ServerInstance(context); si.Guid = scheduler.GetNextServerInstance(reqds, StatDatabaseVersionName, spds); si.Load(); AssignedServerInstance = si; assignedServerInstanceGuid = si.Guid; // *** TODO: find optimal number of partitions // TODO: replace "2" with a value from settings partitionCount = 2 * scheduler.GetServerInstances(reqds, SourceDatabaseVersionName, spds).Length; // Now have to reinitialize to load the assigned server instances InitializeQueryObject(context, scheduler, true); } break; default: throw new NotImplementedException(); } }
private static void AddInstance(ServerInstance app, ServerInstance node) { Debug.Assert(app.Parent == null); //td: error, no nesting node.Parent = app; node.Id = app.Id + "__" + app.Nodes.Count; app.Nodes.Add(node); }
protected override void Execute(CodeActivityContext activityContext) { QueryPartitionBase queryPartition = QueryPartition.Get(activityContext); switch (queryPartition.Query.ExecutionMode) { case ExecutionMode.SingleServer: queryPartition.InitializeQueryObject(null, null, true); break; case ExecutionMode.Graywulf: using (var context = ContextManager.Instance.CreateContext(this, activityContext, ConnectionMode.AutoOpen, TransactionMode.AutoCommit)) { var scheduler = activityContext.GetExtension <IScheduler>(); //queryPartition.DatabaseVersionName = queryPartition.Query.SourceDatabaseVersionName; TODO: delete queryPartition.InitializeQueryObject(context, scheduler, false); var dss = queryPartition.FindRequiredDatasets(); // Check if there are any Graywulf datasets referenced in the query var assignmydb = (dss.Values.FirstOrDefault(ds => !ds.IsSpecificInstanceRequired) == null); // *** TODO: replace this whole thing to use JOIN graphs // If no graywulf datasets are used, use the server containing myDB, // otherwise ask the scheduler for an appropriate server if (dss.Count == 0 || assignmydb) { // use MyDB's server var ef = new EntityFactory(context); var federation = queryPartition.FederationReference.Value; var user = ef.LoadEntity <User>(context.UserGuid); var di = federation.MyDBDatabaseVersion.GetUserDatabaseInstance(user); queryPartition.AssignedServerInstance = di.ServerInstance; } else { // Assign new server instance var si = new ServerInstance(context); si.Guid = scheduler.GetNextServerInstance( dss.Values.Where(x => !x.IsSpecificInstanceRequired).Select(x => x.DatabaseDefinition.Guid).ToArray(), queryPartition.Query.SourceDatabaseVersionName, null); si.Load(); queryPartition.AssignedServerInstance = si; } queryPartition.InitializeQueryObject(context, scheduler, true); EntityGuid.Set(activityContext, queryPartition.AssignedServerInstance.Guid); } break; } }
static void Main(string[] args) { Console.WriteLine("Start"); var server = new ServerInstance("Test Updated Server", new ExtensionsFactory()); var component = new ServerComponent(server); StartLegacyServerAndExecuteFunctions(component); CheckExtensions(server); Console.WriteLine("Finish"); Console.ReadKey(); }
public void Test() { ServerInstance si = new ServerInstance( UOM.ServerName, false, 0, 32 ); ClientInstance ci = new ClientInstance( UOM.ServerName, false ); ci.AddRecvFilterEvent += Ci_AddRecvFilterEvent; si.SendCommand( Command.AddRecvFilterConditional, new PacketFilterInfo(0xF3, new PacketFilterCondition[] { new PacketFilterCondition( 0, new byte[] { 0xF3 }, 1 ) } ).Serialize()); while (true) ; }
public DatabaseInstance GenerateDatabaseInstance(ServerInstance serverInstance, Slice slice, DatabaseVersion databaseVersion) { return(GenerateDatabaseInstance( serverInstance, slice, databaseVersion, databaseDefinition.DatabaseInstanceNamePattern, databaseDefinition.DatabaseNamePattern, databaseVersion.SizeMultiplier, true)); }
static void VerifyRoleHashesAndSendClientList(UdpClient sender, string playerName, string[] roleHashes) { // TODO: verify the role hashes if (roleHashes.Length < LoadedRoleHashes.Count) { NetBase.WriteDebug($"Received role hash list from {sender.EndPoint as IPEndPoint} \"{playerName}\" has less roles than the server, impossible to verify roles."); ConnectedPlayers.Remove(sender.GetPlayer()); sender.Disconnect(); return; } for (int i = 0; i < LoadedRoleHashes.Count; ++i) { string hash = LoadedRoleHashes[i]; if (!roleHashes.Contains(hash)) { NetBase.WriteDebug($"Client {sender.EndPoint as IPEndPoint} \"{playerName}\" missing hash {hash} corresponding to role {LoadedRoleTypes.Values.ElementAt(i).AssemblyQualifiedName}!"); ConnectedPlayers.Remove(sender.GetPlayer()); sender.Disconnect(); return; } else { NetBase.WriteDebug($"{sender.EndPoint as IPEndPoint}: {hash} {LoadedRoleTypes.Values.ElementAt(i).AssemblyQualifiedName} success!"); } } NetWerewolfPlayer playerRef = sender.GetPlayer(); playerRef.Name = playerName; playerRef.RoleListVerified = true; GameInfo.AddPlayerAndAssignId(playerRef); ServerInstance.Send(5, 0u, GenRandomJoinMessage(playerName)); if (GameInfo.Players.Count == 1) { playerRef.IsHost = true; sender.Send(199, true); //SetHost(UdpClient, bool) ServerInstance.Send(5, 0u, $"{playerRef.Name} is now the game master."); } sender.Send(200, playerRef.PlayerID, ConnectedPlayers.Select(p => p.PlayerID).ToArray(), ConnectedPlayers.Select(p => p.Name).ToArray()); // ReceivePlayerList(uint, uint[], string[]); foreach (string hash in ActiveRoleHashes) { sender.Send(190, hash, false); } ServerInstance.Send(1, playerRef.PlayerID, playerRef.Name); // UpdateClientInfo(uint, string) }
public void TestHulk() { //arrange var expectedResult = "Extension Hulk status: true"; //act var server = new ServerInstance("Extensions test", _extensionsFactory); var result = server.LoadHulkExtension(); //assert result.Should().BeEquivalentTo(expectedResult); }
public void TestWidow() { //arrange var expectedResult = "Extension Widow status: false"; //act var server = new ServerInstance("Extensions test", _extensionsFactory); var result = server.LoadWidowExtension(); //assert result.Should().BeEquivalentTo(expectedResult); }
/// <summary> /// 检查livevideo,stopvideo的相关参数 /// </summary> /// <param name="deviceId"></param> /// <param name="channelId"></param> /// <param name="rs"></param> /// <param name="mediaServer"></param> /// <param name="videoChannel"></param> /// <param name="sipChannel"></param> /// <param name="sipDevice"></param> /// <returns></returns> private static bool CheckIt(string deviceId, string channelId, out ResponseStruct rs, out ServerInstance mediaServer, out VideoChannel videoChannel, out SipChannel sipChannel, out SipDevice sipDevice) { mediaServer = null; videoChannel = null; sipChannel = null; sipDevice = null; rs = new ResponseStruct() { Code = ErrorNumber.None, Message = ErrorMessage.ErrorDic ![ErrorNumber.None],
/// <summary> /// 服务注册 /// </summary> /// <param name="serverInstance">服务实例</param> /// <param name="callback">注册完成的回调</param> public void Register(ServerInstance serverInstance, Action <string> callback) { #region 注册服务 if (_consulClient == null) { throw new ArgumentNullException($"consul client"); } var registerResult = ExecuteRegister(serverInstance.Name, serverInstance.DnsEndPoint, callback); if (!registerResult) { throw new Exception($"failed to register service {serverInstance.Name} on host:port {serverInstance.DnsEndPoint.ToString()}"); } #endregion }
public void Test() { ServerInstance si = new ServerInstance(UOM.ServerName, false, 0, 32); ClientInstance ci = new ClientInstance(UOM.ServerName, false); ci.AddRecvFilterEvent += Ci_AddRecvFilterEvent; si.SendCommand(Command.AddRecvFilterConditional, new PacketFilterInfo(0xF3, new PacketFilterCondition[] { new PacketFilterCondition(0, new byte[] { 0xF3 }, 1) }).Serialize()); while (true) { ; } }
public AddEventForm(ServerInstance server, BllUser sender) { InitializeComponent(); this.serverInstance = server; this.Sender = sender; PopulateEventTypeComboBox(sender.EventTypeLib); PopulateAttributeCheckList(); PopulateRecieverTreeView(); if (sender.EventTypeLib.SelectedEntities.Count > 0) { CheckUserNodesAccordingEventType(sender.EventTypeLib.SelectedEntities[0].Entity.Id); } }
static void StopServer(ServerInstance server) { var region = server.ServerListProxy.Parameters.Region; _log.Basic("{0} proxy server stopping...", region); foreach (var proxy in server.Proxies) { proxy.Dispose(); } server.ServerListProxy.Dispose(); server.Loader.Stop(); _log.Basic("{0} proxy server stopped", region); }
/// <summary> /// 服务启动 /// </summary> public static void ServiceStart( ServerServiceDefinition service, ServerInstance serverInstance, List <ChannelOption> channelOptions = null, Action <Exception> whenException = null) { if (service == null) { throw new ArgumentNullException("service"); } var services = new List <ServerServiceDefinition>() { service }; Start(services, channelOptions, whenException, serverInstance); }
static void BroadcastChatMessage(UdpClient sender, string message) { NetWerewolfPlayer p = sender.GetPlayer(); if (p != null) { double secondsSinceLast = (DateTime.Now - p.LastMessageTime).TotalSeconds; if (secondsSinceLast >= 3.5) { ServerInstance.Send(5, p.PlayerID, message); // ReceivedChatMessage(uint, string) p.LastMessageTime = DateTime.Now; } else { sender.Send(5, 0, $"Please wait another {Math.Round(3.5 - secondsSinceLast, 1)} seconds before sending another message."); // ReceivedChatMessage(uint, string) } } }
/// <summary> /// Create an IPC server and start listening for connection. /// </summary> /// <param name="serverName"> /// Name to assign to IPC server. /// </param> /// <param name="writeThrough"> /// If true writes will bypass system cache and go straight to the pipe. /// </param> /// <returns>Index of server created.</returns> internal static int CreateServer(string serverName, bool writeThrough) { if (Count >= myMaxServerCount) throw new ApplicationException("Maximum number of IPC servers exceeded."); if (myServerList != null) { for (int x = 0; x < myServerList.Length; x++) { if (myServerList[x] == null) { Count++; ServerInstance si = new ServerInstance(serverName, writeThrough, x, myMaxServerCount); Interlocked.Exchange<ServerInstance>(ref myServerList[x], si); return x; } } } throw new ApplicationException("Error creating new IPC server."); }
static void ModifyActiveRoleList(UdpClient sender, string roleHash, bool remove) { if (remove) { int activeIndex = ActiveRoleHashes.IndexOf(roleHash); if (activeIndex == -1) { return; } ActiveRoleHashes.RemoveAt(activeIndex); } else { ActiveRoleHashes.Add(roleHash); } ServerInstance.Send(190, roleHash, remove); // ModifyActiveRoleList(string, bool) }
public void PacketFilterTest() { ServerInstance si = new ServerInstance( UOM.ServerName, false, 0, 32 ); ClientInstance ci = new ClientInstance( UOM.ServerName, false ); ci.AddRecvFilterEvent += Ci_AddRecvFilterEvent; ci.SendPacketEvent += Ci_SendPacketEvent; si.SendCommand( Command.AddRecvFilterConditional, new PacketFilterInfo( 0xFF, new PacketFilterCondition[] { new PacketFilterCondition( 2, new byte[] { 0x12, 0x34, 0x56, 0x78 }, 4 ) } ).Serialize() ); byte[] packet = new byte[] { 0xFF, 0x01, 0x12, 0x34, 0x56, 0x78, }; byte[] packet2 = new byte[] { 0xFF, 0x00, 0x78, 0x56, 0x34, 0x12, }; si.SendCommand( Command.SendPacket, 0, (byte) PacketType.Server, packet ); si.SendCommand( Command.SendPacket, 0, (byte) PacketType.Server, packet2 ); lock (m_FinishedLock) { Monitor.Wait( m_FinishedLock ); } ci.Dispose(); si.Dispose(); }
private void InitializeMembers() { this.serverInstance = null; this.databaseDefinition = null; }
internal static bool GetServer(int index, out ServerInstance serverInstance) { serverInstance = ThreadHelper.VolatileRead<ServerInstance>(ref myServerList[index]); return serverInstance == null ? false : true; }