/// <summary> /// Callback for when a client attempts to upload a resource. /// </summary> /// <param name="msg"></param> /// <exception cref="NotImplementedException"></exception> protected override async void ResourceUploadMsg(NetworkResourceUploadMessage msg) { // Do not allow uploading any new resources if it has been disabled. // Note: Any resources uploaded before being disabled will still be kept and sent. if (!Enabled) return; if (!_playerManager.TryGetSessionByChannel(msg.MsgChannel, out var session)) return; // +QUERY only for now. if (!_adminManager.HasAdminFlag(session, AdminFlags.Query)) return; // Ensure the data is under the current size limit, if it's currently enabled. if (SizeLimit > 0f && msg.Data.Length * BytesToMegabytes > SizeLimit) return; ContentRoot.AddOrUpdateFile(msg.RelativePath, msg.Data); // Now we broadcast the message! foreach (var channel in _serverNetManager.Channels) { channel.SendMessage(msg); } if (!StoreUploaded) return; await _serverDb.AddUploadedResourceLogAsync(session.UserId, DateTime.Now, msg.RelativePath.ToString(), msg.Data); }
private void ServerNetManagerOnConnected(object? sender, NetChannelArgs e) { foreach (var (path, data) in ContentRoot.GetAllFiles()) { var msg = new NetworkResourceUploadMessage(); msg.RelativePath = path; msg.Data = data; e.Channel.SendMessage(msg); } }
/// <summary> /// Callback for when the server sends a new resource. /// </summary> /// <param name="msg">The network message containing the data.</param> protected override void ResourceUploadMsg(NetworkResourceUploadMessage msg) { ContentRoot.AddOrUpdateFile(msg.RelativePath, msg.Data); }