This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Net.Http.Headers; | |
using System; | |
using System.IO; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace DotNetCoreStreaming.Results | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.DependencyInjection; | |
namespace DotNetCoreStreaming | |
{ | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DotNetCoreStreaming.Enums | |
{ | |
public enum EventoEnum | |
{ | |
Insert = 1, | |
Update = 2 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DotNetCoreStreaming.Models | |
{ | |
public class Cliente | |
{ | |
public long Id { get; set; } | |
public string Nome { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static ConcurrentBag<StreamWriter> _clients; | |
static ClienteController() | |
{ | |
_clients = new ConcurrentBag<StreamWriter>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public IActionResult Post(Cliente cliente) | |
{ | |
//Fazer o Insert | |
EnviarEvento(cliente, EventoEnum.Insert); | |
return Ok(); | |
} | |
[HttpPut] | |
public IActionResult Put(Cliente cliente) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
[Route("Streaming")] | |
public IActionResult Stream() | |
{ | |
return new PushStreamResult(OnStreamAvailable, "text/event-stream", HttpContext.RequestAborted); | |
} | |
private void OnStreamAvailable(Stream stream, CancellationToken requestAborted) | |
{ | |
var wait = requestAborted.WaitHandle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DotNetCoreStreaming.Enums; | |
using DotNetCoreStreaming.Models; | |
using DotNetCoreStreaming.Results; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Newtonsoft.Json; | |
using System.Collections.Concurrent; | |
using System.IO; | |
using System.Threading; | |
using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print('Hello World!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vetor <- c(1, 5, 4) | |
vetor | |
# SAÍDA: 1 5 4 |
OlderNewer