aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/api/api/Program.cs1
-rw-r--r--backend/api/api/Services/ChatHub.cs6
-rw-r--r--backend/api/api/Services/IChat.cs8
-rw-r--r--backend/api/api/Services/MlConnectionService.cs8
4 files changed, 7 insertions, 16 deletions
diff --git a/backend/api/api/Program.cs b/backend/api/api/Program.cs
index 6f1116d9..576093fe 100644
--- a/backend/api/api/Program.cs
+++ b/backend/api/api/Program.cs
@@ -36,7 +36,6 @@ builder.Services.AddScoped<IPredictorService, PredictorService>();
builder.Services.AddScoped<IFileService, FileService>();
builder.Services.AddScoped<IJwtToken, JwtToken>();
builder.Services.AddScoped<IExperimentService, ExperimentService>();
-builder.Services.AddScoped<IChat,ChatHub>();
builder.Services.AddHostedService<TempFileService>();
builder.Services.AddHostedService<FillAnEmptyDb>();
diff --git a/backend/api/api/Services/ChatHub.cs b/backend/api/api/Services/ChatHub.cs
index d343c758..3dd6ab3e 100644
--- a/backend/api/api/Services/ChatHub.cs
+++ b/backend/api/api/Services/ChatHub.cs
@@ -8,9 +8,9 @@ using System.Threading.Tasks;
namespace api.Services
{
- public class ChatHub :Hub,IChat
+ public class ChatHub :Hub
{
- static readonly Dictionary<string,string> Users=new Dictionary<string,string>();
+ static public readonly Dictionary<string,string> Users=new Dictionary<string,string>();
private readonly IJwtToken _tokenService;
public ChatHub(IJwtToken tokenService)
{
@@ -22,7 +22,7 @@ namespace api.Services
string token=Context.GetHttpContext().Request.Query["access_token"];
string id=_tokenService.TokenToId(token);
Users.Add(id,Context.ConnectionId);
- await SendDirect(id, "poruka");
+ //await SendDirect(id, "poruka");
//await Send(Context.ConnectionId);
await base.OnConnectedAsync();
diff --git a/backend/api/api/Services/IChat.cs b/backend/api/api/Services/IChat.cs
deleted file mode 100644
index 8a905868..00000000
--- a/backend/api/api/Services/IChat.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace api.Services
-{
- public interface IChat
- {
- Task SendDirect(string id, string message);
- Task Send(string message);
- }
-} \ No newline at end of file
diff --git a/backend/api/api/Services/MlConnectionService.cs b/backend/api/api/Services/MlConnectionService.cs
index 8523a3ac..2ac977d9 100644
--- a/backend/api/api/Services/MlConnectionService.cs
+++ b/backend/api/api/Services/MlConnectionService.cs
@@ -12,13 +12,13 @@ namespace api.Services
private RestClient client;
private readonly IDatasetService _datasetService;
private readonly IModelService _modelService;
- private readonly IChat _chat;
+ private readonly IHubContext<ChatHub> _ichat;
- public MlConnectionService(IDatasetService datasetService,IChat chat)
+ public MlConnectionService(IDatasetService datasetService,IHubContext<ChatHub> ichat)
{
this.client = new RestClient("http://127.0.0.1:5543");
_datasetService=datasetService;
- _chat=chat;
+ _ichat=ichat;
}
public async Task<string> SendModelAsync(object model, object dataset)//Don't Use
@@ -57,7 +57,7 @@ namespace api.Services
Dataset newDataset = JsonConvert.DeserializeObject<Dataset>(result.Content);
newDataset.isPreProcess = true;
_datasetService.Update(newDataset);
- await _chat.SendDirect(id, "Procesed dataset with name "+newDataset.name);
+ await _ichat.Clients.Client(ChatHub.Users[id]).SendAsync("Notify", "Preprocessed dataset with name "+newDataset.name);
return;
}