implements user fs alimentation from web sockets

vnext v1.0.6-rc16
Paul Schneider 4 years ago
parent 85a88e1f10
commit 4a9bd7863a
6 changed files with 42 additions and 9 deletions

@ -61,6 +61,6 @@ namespace Yavsc
public const string LivePath = "/live/cast"; public const string LivePath = "/live/cast";
public const string StreamingPath = "/api/stream/Put"; public const string StreamingPath = "/api/stream/put";
} }
} }

@ -27,8 +27,11 @@ namespace Yavsc.ApiControllers
this.logger = loggerFactory.CreateLogger<FileSystemStreamController>(); this.logger = loggerFactory.CreateLogger<FileSystemStreamController>();
this.liveProcessor = liveProcessor; this.liveProcessor = liveProcessor;
} }
[Authorize, Route("put/{filename}")]
public async Task<IActionResult> Put([ValidRemoteUserFilePath] string filename) public async Task<IActionResult> Put([ValidRemoteUserFilePath] string filename)
{ {
logger.LogInformation("Put : " + filename);
if (!HttpContext.WebSockets.IsWebSocketRequest) if (!HttpContext.WebSockets.IsWebSocketRequest)
return HttpBadRequest("not a web socket"); return HttpBadRequest("not a web socket");
if (!HttpContext.User.Identity.IsAuthenticated) if (!HttpContext.User.Identity.IsAuthenticated)
@ -36,10 +39,12 @@ namespace Yavsc.ApiControllers
var subdirs = filename.Split('/'); var subdirs = filename.Split('/');
var filePath = subdirs.Length > 1 ? string.Join("/", subdirs.Take(subdirs.Length-1)) : null; var filePath = subdirs.Length > 1 ? string.Join("/", subdirs.Take(subdirs.Length-1)) : null;
var shortFileName = subdirs[subdirs.Length-1]; var shortFileName = subdirs[subdirs.Length-1];
if (shortFileName.IsValidShortFileName()) if (!shortFileName.IsValidShortFileName())
{
logger.LogInformation("invalid file name : " + filename);
return HttpBadRequest("invalid file name"); return HttpBadRequest("invalid file name");
}
logger.LogInformation("validated: api/stream/Put: "+filename);
var userName = User.GetUserName(); var userName = User.GetUserName();
var hubContext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<ChatHub>(); var hubContext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
string url = string.Format( string url = string.Format(
@ -59,7 +64,7 @@ namespace Yavsc.ApiControllers
logger.LogInformation($"Saving flow to {destDir}"); logger.LogInformation($"Saving flow to {destDir}");
var userId = User.GetUserId(); var userId = User.GetUserId();
var user = await dbContext.Users.FirstAsync(u => u.Id == userId); var user = await dbContext.Users.FirstAsync(u => u.Id == userId);
logger.LogInformation("Accepting stream ...");
await liveProcessor.AcceptStream(HttpContext, user, destDir, shortFileName); await liveProcessor.AcceptStream(HttpContext, user, destDir, shortFileName);
return Ok(); return Ok();
} }

@ -127,7 +127,7 @@ namespace cli {
public CommandLineApplication Integrate(CommandLineApplication rootApp) public CommandLineApplication Integrate(CommandLineApplication rootApp)
{ {
CommandLineApplication streamCmd = rootApp.Command("stream", CommandLineApplication streamCmd = rootApp.Command("nstream",
(target) => (target) =>
{ {
target.FullName = "Stream to server"; target.FullName = "Stream to server";
@ -172,7 +172,7 @@ namespace cli {
async Task DoStream (Stream stream) async Task DoStream (Stream stream)
{ {
_tokenSource = new CancellationTokenSource(); _tokenSource = new CancellationTokenSource();
var url = _cxSettings.StreamingUrl + "/" + HttpUtility.UrlEncode(_destArg.Value); var url = _cxSettings.NStreamingUrl + "/" + HttpUtility.UrlEncode(_destArg.Value);
_logger.LogInformation("Connecting to " + url); _logger.LogInformation("Connecting to " + url);
await _client.ConnectAsync(new Uri(url), _tokenSource.Token); await _client.ConnectAsync(new Uri(url), _tokenSource.Token);

@ -116,12 +116,13 @@ namespace cli
CommandOption rootCommandHelpOption = cliapp.HelpOption("-? | -h | --help"); CommandOption rootCommandHelpOption = cliapp.HelpOption("-? | -h | --help");
(new SendMailCommandProvider()).Integrate(cliapp); new SendMailCommandProvider().Integrate(cliapp);
(new GenerateJsonSchema()).Integrate(cliapp); new GenerateJsonSchema().Integrate(cliapp);
(new AuthCommander(loggerFactory)).Integrate(cliapp); (new AuthCommander(loggerFactory)).Integrate(cliapp);
(new CiBuildCommand()).Integrate(cliapp); (new CiBuildCommand()).Integrate(cliapp);
(new GenerationCommander()).Integrate(cliapp); (new GenerationCommander()).Integrate(cliapp);
(new Streamer(loggerFactory, cxSettings, usercxSettings )).Integrate(cliapp); (new Streamer(loggerFactory, cxSettings, usercxSettings )).Integrate(cliapp);
new NStreamer(loggerFactory, cxSettings, usercxSettings ).Integrate(cliapp);
if (args.Length == 0) if (args.Length == 0)
{ {

@ -42,5 +42,14 @@ namespace cli
return Port==0 ? $"ws://{Authority}"+Constants.LivePath: return Port==0 ? $"ws://{Authority}"+Constants.LivePath:
$"ws://{Authority}:{Port}"+Constants.LivePath; $"ws://{Authority}:{Port}"+Constants.LivePath;
} } } }
[NotMapped]
[JsonIgnore]
public string NStreamingUrl { get {
return Port==0 ? $"ws://{Authority}"+Constants.StreamingPath:
$"ws://{Authority}:{Port}"+Constants.StreamingPath;
} }
} }
} }

@ -0,0 +1,18 @@
{
"UserConnection": {
"UserName": "Paul",
"AccessToken": "IvvrnJye2b7CSFp2Hj3mEEK1-7EMbLLGJATQHAwOlRt5sIcm9aMH85kJMAxDb4yIzL76G7maoIlaWuSyhhS3qfcIB04WcVnCVdmw22ncMs8rk_L0yGuLdNBnF3HuhZXpjD-AjpLJ1TdE0q3c-yakkP_EWTjM9I00a1gGop4bgE_-LAa2uoLeaCj0dbe95OSvVKJWJ4MU0fjlvqAaUx-EC4HYicUMEQvJviR0FyyMKPYYyx4jyu_bgYbhmKX9LoE5VeEDEMsyXZE0fxqdfnflICduUqrprCvQfLoG4DZ8o7ivjoak3-xiP7CFaF1vou89mO1c9BcJYUjcZXPgNYC7K9QHwFC5sPDkOHdijUo9xfieRaaqge5tEHlZAs3H_u-bGWft7xjxHOVUPSRzzYygR27alVSUIt6rt28FoLsEGYQaVK5QNzIbOE0RVU40vQb5a6JzcTcjTtRxCMn3FneKZtilEHb2TooUy4YbmhbnDIKsa0ZMMBEshyEel8oCWz9SITjm24FbdCmUvSKOlkHhIcnSM8oez9qhDlzzcsKzahbNeO-EBINW-6qBlKISQbFmfy-zO134JEkcpfA9NybGcYPZWL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MA86937IrCCFZsGBhHAm-yszHXjVjPCr7gAJYaBjneAUAoseEYK0GaOVGXfhxQcURXtM9TyH3pgHjccOzq300Djv-BpfQZcSZnQf59kulL_gt--451r8UIw3wxQ6BD5fGVF_MrilUluLyhoqoGZJbiHFyL-miKjW7feGFuogVyee0nIO1Me-7T-aTQnn-LivP9avyHab4eGwg1nfUbEspA21vmz2UXkUvKvT-JRGmSxlYineeJURQMcGGbcvr9GbFy1A_vbImUSw_Tx0u7_7jwxkDwlTt5WvGVsFFHsj9vgtNSnWHRzbGhbOSBocg0eWylgmYy3yZtdajRx6xQluRUewP_K66GsmA6xVmekUo0_ZzUPj61VQzTMR-knYE-pCd6V_qGS4qtUNeQ5nPLWT6hRPvnd3kK7CS22ijEErm3LaOY2DogGYIoBLvmdande226KW48hUgQPxsmOLoUl1tXMYsiRqHKAnWlzg4-e_BfRe3YsMUwlNPcqYf0hQ-mE-j4fVo79XJFFSWF8WxYKed-imDYeK9b6bQPP3ZPaqiMy7_d9Fxnb3i2Oo4XQPmrTpDkHbMovslBfBoJW4RSpXo3cn0QqcCDG2KfFS8HIYr68jXnyx7Ws3MeswdyEFSqx-XWmZa"
},
"Connection": {
"ClientId": "53f4d5da-93a9-4584-82f9-b8fdf243b002",
"ClientSecret": "blouh",
"Authority": "localhost",
"Audience": "localhost",
"SiteAccessSheme": "http",
"Port": 5000,
"Scope": "profile"
}
}
Loading…