Skip to content

Commit

Permalink
fix: update service for smalltalk api
Browse files Browse the repository at this point in the history
  • Loading branch information
live-dev999 committed Apr 10, 2022
1 parent 15a1906 commit ddf0e9b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "6.0.3",
"commands": [
"dotnet-ef"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ public ChatController(IChatHub chatHub)
this.chatHub = chatHub;
}
[HttpGet]
public void Test()
public IActionResult Test()
{
chatHub.UpdateMessages();
return Ok("Ok");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;

namespace O2NextGen.SmallTalk.SignalrHub.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}

// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}

// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}

// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}

// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ public interface IChatHub {
}
public class ChatHub : Hub, IChatHub
{
string username;
public async Task NewUserAsync(string username)
{
await Groups.AddToGroupAsync(Context.ConnectionId, username);
this.username = username;
await base.OnConnectedAsync();
}

public async Task UpdateMessages()
{
await Clients.All.SendAsync("OnUpdateMessage");
await Clients.Group(username).SendAsync("getRoomUsers");
//await Groups..All.SendAsync("OnUpdateMessage");
}

//public override async Task OnConnectedAsync()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>bc1a7d3c-820d-4431-a0c7-d51b4a253b6d</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using O2NextGen.SmallTalk.SignalrHub.Hubs;

Expand All @@ -11,6 +12,11 @@ public class Startup
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
var mvcBuilder = services.AddMvcCore(options => {
//options.Filters.Add<ApiExceptionFilter>();
});
mvcBuilder.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
mvcBuilder.AddJsonFormatters();
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
Expand Down

0 comments on commit ddf0e9b

Please sign in to comment.