private void RegisterEvents() { playerHandler = new PlayerHandler(); serverHandler = new ServerHandler(); warheadHandler = new WarheadHandler(); scp106Handler = new Scp106Handler(); // Player Player.FailingEscapePocketDimension += playerHandler.OnFailingEscapePocketDimension; Player.EscapingPocketDimension += playerHandler.OnEscapingPocketDimension; Player.Hurting += playerHandler.OnHurting; Player.Shooting += playerHandler.OnShooting; Player.ActivatingGenerator += playerHandler.OnActivatingGenerator; Player.EnteringFemurBreaker += playerHandler.OnEnteringFemurBreaker; Player.Destroying += playerHandler.OnDestroying; Player.Died += playerHandler.OnDied; Player.ChangingRole += playerHandler.OnChangingRole; Player.SpawningRagdoll += playerHandler.OnSpawningRagdoll; // Server Server.WaitingForPlayers += serverHandler.OnWaitingForPlayers; Server.RespawningTeam += serverHandler.OnRespawningTeam; Server.EndingRound += serverHandler.OnEndingRound; // Warhead Warhead.Detonated += warheadHandler.OnDetonated; // Scp-106 Scp106.Containing += scp106Handler.OnContaining; }
private void UnregisterEvents() { // Player Player.FailingEscapePocketDimension -= playerHandler.OnFailingEscapePocketDimension; Player.EscapingPocketDimension -= playerHandler.OnEscapingPocketDimension; Player.Hurting -= playerHandler.OnHurting; Player.Shooting -= playerHandler.OnShooting; Player.ActivatingGenerator -= playerHandler.OnActivatingGenerator; Player.EnteringFemurBreaker -= playerHandler.OnEnteringFemurBreaker; Player.Destroying -= playerHandler.OnDestroying; Player.Died -= playerHandler.OnDied; Player.ChangingRole -= playerHandler.OnChangingRole; Player.SpawningRagdoll -= playerHandler.OnSpawningRagdoll; // Server Server.WaitingForPlayers -= serverHandler.OnWaitingForPlayers; Server.RespawningTeam -= serverHandler.OnRespawningTeam; Server.EndingRound -= serverHandler.OnEndingRound; // Warhead Warhead.Detonated -= warheadHandler.OnDetonated; // Scp-106 Scp106.Containing -= scp106Handler.OnContaining; playerHandler = null; serverHandler = null; warheadHandler = null; scp106Handler = null; }
public Client(TcpClient client, ServerHandler handler, bool ssl) { Handler = handler; RawClient = client; if (!ssl) { Writer = new StreamWriter(RawClient.GetStream()); Reader = new StreamReader(RawClient.GetStream()); } else { if (cert == null) { var path = Path.GetFullPath(Path.Combine(References.GCPD_FOLDER, Config.User.Ssl_Cert_Path)); if (!(new FileInfo(path)).Exists) throw new Exception("certificate does not exist at " + path); cert = new X509Certificate2(path, Config.User.Ssl_Cert_Pass); } try { SslStream stream = new SslStream(RawClient.GetStream(), false); stream.AuthenticateAsServer(cert, false, System.Security.Authentication.SslProtocols.Tls, false); Writer = new StreamWriter(stream); Reader = new StreamReader(stream); } catch (IOException e) { client.Close(); throw e; } } ThreadPool.QueueUserWorkItem((object o) => { AssignHostName(); }); }
public override IServer AddHandler(ServerType type, ServerHandler handler) { switch (type) { case ServerType.Started: OnStarted += handler; break; case ServerType.Accepted: OnAccepted += handler; break; case ServerType.Sended: OnSended += handler; break; case ServerType.Received: OnRecieved += handler; break; case ServerType.Disconnected: OnDisconnected += handler; break; case ServerType.Stopped: OnStopped += handler; break; } return(this); }
public IActionResult Delete([FromServices] ServerHandler handler, [FromRoute] Guid serverId) { var command = new DeleteServerCommand(serverId); var response = (DefaultCommandResult)handler.Handle(command); return(this.DefaultCommandResultToActionResult(response)); }
/// <summary> /// Gets the size of a remote file, in bytes. /// </summary> /// <param name="path">The full or relative path of the file</param> /// <param name="defaultValue">Value to return if there was an error obtaining the file size, or if the file does not exist</param> /// <returns>The size of the file, or defaultValue if there was a problem.</returns> public virtual long GetFileSize(string path, long defaultValue = -1) { // verify args if (path.IsBlank()) { throw new ArgumentException("Required parameter is null or blank.", "path"); } path = path.GetFtpPath(); LogFunc(nameof(GetFileSize), new object[] { path }); // execute server-specific file size fetching logic, if any if (ServerHandler != null && ServerHandler.IsCustomFileSize()) { return(ServerHandler.GetFileSize(this, path)); } if (!HasFeature(FtpCapability.SIZE)) { return(defaultValue); } var sizeReply = new FtpSizeReply(); #if !CORE14 lock (m_lock) { #endif GetFileSizeInternal(path, sizeReply, defaultValue); #if !CORE14 } #endif return(sizeReply.FileSize); }
/// <inheritdoc/> public override void OnEnabled() { Instance = this; serverHandler = new ServerHandler(); harmonyInstance = new Harmony($"com.{nameof(CustomItems)}.galaxy-{DateTime.Now.Ticks}"); harmonyInstance.PatchAll(); Config.LoadItems(); Config.ItemConfigs.Scp127s.Register(); Config.ItemConfigs.Scp714s.Register(); Config.ItemConfigs.Scp1499s.Register(); Config.ItemConfigs.Scp2818s.Register(); Config.ItemConfigs.AutoGuns.Register(); Config.ItemConfigs.C4Charges.Register(); Config.ItemConfigs.DeflectorSheilds.Register(); Config.ItemConfigs.EmpGrenades.Register(); Config.ItemConfigs.GrenadeLaunchers.Register(); Config.ItemConfigs.ImplosionGrenades.Register(); Config.ItemConfigs.LethalInjections.Register(); Config.ItemConfigs.LuckyCoins.Register(); Config.ItemConfigs.MediGuns.Register(); Config.ItemConfigs.SniperRifle.Register(); Config.ItemConfigs.TranquilizerGun.Register(); Config.ItemConfigs.AntiMemeticPills.Register(); Server.ReloadedConfigs += serverHandler.OnReloadingConfigs; base.OnEnabled(); }
/// <inheritdoc/> public override void OnDisabled() { Config.ItemConfigs.Scp127s.Unregister(); Config.ItemConfigs.Scp714s.Unregister(); Config.ItemConfigs.Scp1499s.Unregister(); Config.ItemConfigs.Scp2818s.Unregister(); Config.ItemConfigs.AutoGuns.Unregister(); Config.ItemConfigs.C4Charges.Unregister(); Config.ItemConfigs.DeflectorSheilds.Unregister(); Config.ItemConfigs.EmpGrenades.Unregister(); Config.ItemConfigs.GrenadeLaunchers.Unregister(); Config.ItemConfigs.ImplosionGrenades.Unregister(); Config.ItemConfigs.LethalInjections.Unregister(); Config.ItemConfigs.LuckyCoins.Unregister(); Config.ItemConfigs.MediGuns.Unregister(); Config.ItemConfigs.SniperRifle.Unregister(); Config.ItemConfigs.TranquilizerGun.Unregister(); Config.ItemConfigs.AntiMemeticPills.Unregister(); Server.ReloadedConfigs -= serverHandler.OnReloadingConfigs; harmonyInstance?.UnpatchAll(); serverHandler = null; Instance = null; base.OnDisabled(); }
private void OnRenamed(object source, RenamedEventArgs e) { string oldPath = e.OldFullPath; string newPath = e.FullPath; string paraOldPath = oldPath.Substring(CommonStaticVariables.homePath.Length, oldPath.Length - CommonStaticVariables.homePath.Length); string paraNewPath = newPath.Substring(CommonStaticVariables.homePath.Length, newPath.Length - CommonStaticVariables.homePath.Length); if (Directory.Exists(newPath)) { string lastWriteTime = Directory.GetLastWriteTime(newPath).ToString(); if (!ServerHandler.renameDirectory(paraOldPath, paraNewPath, lastWriteTime)) { insMainFrm.notifyIcon1.BalloonTipText = "同步失败"; insMainFrm.notifyIcon1.ShowBalloonTip(200); } } if (File.Exists(newPath)) { string lastWriteTime = File.GetLastWriteTime(newPath).ToString(); if (!ServerHandler.renameFile(paraOldPath, paraNewPath, lastWriteTime)) { insMainFrm.notifyIcon1.BalloonTipText = "同步失败"; insMainFrm.notifyIcon1.ShowBalloonTip(200); } } }
/// <summary> /// Initialize our client handlers /// </summary> public void RegisterServerHandlers() { m_ServerHandler = new ServerHandler[Common.MaxHeaderId]; m_ServerHandler[Common.SERVER_LAUNCHER_LOGIN] = new ServerHandler(HandleLogin); m_ServerHandler[Common.SERVER_LAUNCHER_INFO] = new ServerHandler(HandleInfo); m_ServerHandler[Common.SERVER_LAUNCHER_UPDATE] = new ServerHandler(HandleLauncherUpdate); }
/// <inheritdoc/> public override void OnEnabled() { serverHandler = new ServerHandler(); playerHandler = new PlayerHandler(); harmonyInstance = new Harmony($"com.{nameof(CustomItems)}.galaxy-{DateTime.Now.Ticks}"); harmonyInstance.PatchAll(); Config.LoadItems(); RegisterItems(); Log.Debug("Checking for Subclassing...", Config.IsDebugEnabled); try { CheckAndPatchSubclassing(); } catch (Exception) { Log.Debug("Subclassing not installed.", Config.IsDebugEnabled); } Server.ReloadedConfigs += serverHandler.OnReloadingConfigs; base.OnEnabled(); }
public void Recieve(byte[] bytes) { NetData message = NetData.RecoverBytes(bytes); if (message != null && message.number > lastMessageNumber) { if (ServerHandler.clients.Contains(message.sender.ID)) { if ((ServerHandler.clients[message.sender.ID] as NetUser).udpConnection == null) { NetUser.OnUserConnectedUDP(message.sender); } netUser = ServerHandler.clients[message.sender.ID] as NetUser; netUser.udpConnection = this; } else { netUser = new NetUser(message.sender); netUser.udpConnection = this; ServerHandler.AddConnection(netUser); NetUser.OnUserConnectedUDP(message.sender); } NetUser.OnUdpMessageHandleCallback(bytes, message, netUser); lastMessageNumber = message.number; } }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddServerSideBlazor(); services.AddLanguageContainer(Assembly.GetExecutingAssembly(), CultureInfo.GetCultureInfo(CultureInfo.CurrentCulture.Name)); services.AddSyncfusionBlazor(); services.AddBlazoredLocalStorage(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = Configuration["Jwt:Issuer"], ValidAudience = Configuration["Jwt:Audience"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"])) }; }); ServerHandler serverHandler = new ServerHandler(Configuration); services.AddScoped(implementation => serverHandler); services.AddScoped(implementation => serverHandler.SignInService); services.AddScoped(implementation => serverHandler.SignUpService); services.AddScoped <ServerHandler>(); services.AddScoped <AuthService>(); services.AddScoped <AuthenticationStateProvider, CustomAuthenticationStateProvider>(); }
private void buttonStart_Click(object sender, EventArgs e) { Server = new ServerHandler(); Server.PreventDuplicate = Dupe.Nothing; Server.SynchronizingObject = this; Server.ReceivedTcp += Server_ReceivedTcp; Server.NewConnection += Server_NewConnection; Server.LostConnection += Server_LostConnection; Server.AuthValidation = Server_AuthValidation; Server.Start(IPAddress.Any, (int)Port.Value, -1, 50); //3rd is the max amount of connects, 4th is the amount of queued logins WriteLine("Server Started"); }
// Use this for initialization void Start() { server = FindObjectOfType<ServerHandler>(); text.text = server.PlayerUsername; }
IEnumerator SaveCoroutine(string saveGameData) { if (server == null) server = FindObjectOfType<ServerHandler>(); WWWForm saveForm = new WWWForm (); saveForm.AddField ("myform_username", server.PlayerUsername); saveForm.AddField ("myform_password", server.PlayerPassword); saveForm.AddField ("myform_savedata", saveGameData); saveForm.AddField ("myform_hash", server.SecretKey); WWW www = new WWW (server.Url + "/php/SaveGame.php", saveForm); yield return www; if (www.error != null) { Debug.LogError(www.error); } else { Debug.Log(www.text); saveGameCanvas = Instantiate(Resources.Load("Prefabs/UI/SaveGameCanvas")) as GameObject; saveGameCanvas.SetActive(true); yield return new WaitForSeconds(1f); saveGameCanvas.SetActive(false); } }
// Use this for initialization void Start() { response.text = ""; server = FindObjectOfType<ServerHandler>(); }
public ChannelManager(ServerHandler handler) { this.Handler = handler; }
// Use this for initialization void Start() { server = FindObjectOfType<ServerHandler>(); levelManager = FindObjectOfType<LevelManager>(); }