Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ChatChannel/ChatHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@

namespace ChatChannel
{


public sealed class ChatHost() {
public IHost Host { get; set; }


}
}
3 changes: 0 additions & 3 deletions Riverside.Graphite.Channels/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@ public HomeController(IConfiguration configuration, IHubCommander commander, ILo
_logger = logger;
_commander = commander;
_configuration = configuration;

}

public IActionResult Index()
{

ViewData["GraphApiResult"] = User.GetDisplayName();
return View();
}

[HttpGet("users/all")]
public IActionResult GetallMsalUsers()
{

var users = AzureChat.ConnectedIds.Select(t => t.Value).ToList(); // _commander?.MsalCurrentUsers;
return new JsonResult(users!.Select(x => x).ToArray());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FireCore.Services;
using FireCore.Services;
using Microsoft.AspNetCore.Mvc;

namespace FireCore.Controllers
Expand All @@ -15,7 +15,6 @@ public MessageBoardController(IHubContextStore hubContextStore, IHubCommander co
_contextStore = hubContextStore;
_commander = commander;
_configuration = configuration;

}
#endregion;

Expand All @@ -30,10 +29,9 @@ public async Task<IActionResult> Index()
foreach (var cookie in Request.Cookies)
{ Response.Cookies.Delete(cookie.Key); }
Console.Write(e.Message!.ToString());
};
}

return Redirect("~/");

}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using FireCore.Services;
Expand All @@ -8,7 +8,6 @@

namespace FireCore.Controllers
{

[ApiController]
public class NegotiateController : ControllerBase
{
Expand All @@ -22,7 +21,6 @@ public NegotiateController(IHubContextStore store, IConfiguration configuration)
_messageHubContext = store.MessageHubContext;
_chatHubContext = store.ChatHubContext;
_enableDetailedErrors = configuration.GetValue(EnableDetailedErrors, false);

}

[HttpPost("message/negotiate")]
Expand Down
7 changes: 1 addition & 6 deletions Riverside.Graphite.Channels/Data/Database/SessionContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FireCore.Data.Models;
using FireCore.Data.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;

Expand All @@ -18,7 +18,6 @@ public SessionContext(IWebHostEnvironment webHostEnvironment)
public SessionContext(DbContextOptions<SessionContext> options)
: base(options)
{

}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
Expand All @@ -31,13 +30,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
model.Property(e => e.DateTime).HasDefaultValue(DateTimeOffset.Now);
modelBuilder.Entity<SessionDbEntity>();

});

base.OnModelCreating(modelBuilder);
}

}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FireCore.Data.Models.Contracts
namespace FireCore.Data.Models.Contracts
{
public interface ISessionDbEntity
{
Expand All @@ -7,6 +7,5 @@ public interface ISessionDbEntity
public string? PartnerName { get; set; }
public string? SessionId { get; set; }
public DateTimeOffset DateTime { get; set; }

}
}
1 change: 0 additions & 1 deletion Riverside.Graphite.Channels/Models/ErrorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

}
5 changes: 1 addition & 4 deletions Riverside.Graphite.Channels/Models/MessageBoardViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using FireCore.Services;
using FireCore.Services;
using FireCore.Services.Hubs;

namespace FireCore.Models
{

using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using System;
Expand Down Expand Up @@ -72,7 +71,6 @@ public Task Initialize()

var users = AzureChat.ConnectedIds?.Select(t => t.Value).ToList();
_commander!.MsalCurrentUsers = users!.ToList();

}
catch (Exception e)
{
Expand All @@ -82,5 +80,4 @@ public Task Initialize()
return Task.CompletedTask;
}
}

}
6 changes: 0 additions & 6 deletions Riverside.Graphite.Channels/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ public static void Main(string[] args)
var builder = Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(args);
builder.WebHost.UseKestrel(x => x.ListenAnyIP(5000));
Startup(builder);

}

public static void Startup(WebApplicationBuilder builder) {

_ = builder.Services.AddHttpClient();
_ = builder.Services.AddRouting();
_ = builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
Expand All @@ -51,7 +49,6 @@ public static void Startup(WebApplicationBuilder builder) {
new Claim(ClaimTypes.NameIdentifier, context?.Request?.Query["username"]!)
];
options.ServerStickyMode = Microsoft.Azure.SignalR.ServerStickyMode.Preferred;

});

_ = builder.Services.AddSingleton<IMessageHandler, AzureDataTableMessages>();
Expand Down Expand Up @@ -94,7 +91,6 @@ public static void Startup(WebApplicationBuilder builder) {
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapHub<AzureChat>("/chat");

});

app.MapControllerRoute(
Expand All @@ -103,8 +99,6 @@ public static void Startup(WebApplicationBuilder builder) {


app.Run();

}

}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Azure;

namespace FireCore.Services.Contracts.MessageHandler.AzureTableMessageStorage
{

public class MessageEntity : Azure.Data.Tables.ITableEntity
{
public string RowKey { get; set; } = default!;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Azure.Data.Tables;
using Azure.Data.Tables;


namespace FireCore.Services.Contracts.SessionHandler.AzureTableSessionStorage
Expand Down Expand Up @@ -29,32 +29,26 @@ public AzureDataTableSession(IConfiguration configuration, SignalRService signal
}
public async Task<Task> InitializeTables()
{

_tableServiceClient = new(_configuration?.GetRequiredSection("AzureStorage").Value!);
_tableClient = _tableServiceClient?.GetTableClient("SessionTable");
await _tableClient!.CreateIfNotExistsAsync().ConfigureAwait(false);
return Task.CompletedTask;

}


internal async Task<Session?> SetPrivateSession(string userName, string partnerName)
{

var result = _tableClient?.QueryAsync<SQL_SESSION_ENTITY>(x => x.PartitionKey == userName && x.RowKey == partnerName).AsPages().ToBlockingEnumerable();

if (result!.Count() > 0)
{
return await Task.FromResult<Session?>(new Session(result?.First().Values!.Select(x => x.SessionId).ToString()!));
}
else { return null; }


}

public async Task<bool> IsUserActive(string roomNameUserName)
{

var answer = _tableClient?.QueryAsync<SQL_SESSION_ENTITY>(x => x.PartitionKey == roomNameUserName).AsPages().ToBlockingEnumerable();

if (answer!.Count() > 0)
Expand All @@ -63,11 +57,9 @@ public async Task<bool> IsUserActive(string roomNameUserName)
}

return await Task.FromResult(false);

}
public async Task<bool> DeleteUserSession(string userName, string partnerName)
{

var answer = _tableClient?.QueryAsync<SQL_SESSION_ENTITY>(x => x.PartitionKey == userName && x.RowKey == partnerName);

var batchIt = new List<TableTransactionAction>();
Expand All @@ -85,7 +77,6 @@ public async Task<bool> DeleteUserSession(string userName, string partnerName)
}

return false;

}
public async Task<Session> GetOrCreateSessionAsync(string userName, string partnerName)
{
Expand All @@ -95,7 +86,6 @@ public async Task<Session> GetOrCreateSessionAsync(string userName, string partn

if (isJointRoom is null)
{

var isPartnerJoint = await SetPrivateSession(partnerName, userName);

if (isPartnerJoint is not null)
Expand All @@ -114,7 +104,6 @@ public async Task<Session> GetOrCreateSessionAsync(string userName, string partn
await _tableClient!.AddEntityAsync(new SQL_SESSION_ENTITY(partnerName, userName, session));
return session;
}

}
}

Expand All @@ -124,7 +113,6 @@ public async Task<Session> GetOrCreateSessionAsync(string userName, string partn

if (sql?.ToBlockingEnumerable().Count() > 0)
{

var sessionExists = _tableClient?.GetEntityIfExists<SQL_SESSION_ENTITY>(userName, partnerName);

if (sessionExists!.HasValue)
Expand All @@ -147,12 +135,10 @@ public async Task<Session> GetOrCreateSessionAsync(string userName, string partn
await _tableClient!.AddEntityAsync(new SQL_SESSION_ENTITY(userName, partnerName, newSession));
return newSession;
}

}

public async Task<List<SQL_SESSION_ENTITY>> GetSessionBySessionId(string sessionId)
{

var answer = _tableClient?.QueryAsync<SQL_SESSION_ENTITY>(x => x.SessionId == sessionId).AsPages();

var sessions = new List<SQL_SESSION_ENTITY>();
Expand All @@ -163,11 +149,9 @@ public async Task<List<SQL_SESSION_ENTITY>> GetSessionBySessionId(string session
}

return sessions;

}
public async Task<KeyValuePair<string, Session>[]> GetLatestSessionsAsync(string userName)
{

var result = _tableClient?.QueryAsync<SQL_SESSION_ENTITY>(s => s.PartitionKey == userName).ConfigureAwait(false);

var sessions = new SortedDictionary<string, Session>();
Expand All @@ -179,9 +163,6 @@ public async Task<KeyValuePair<string, Session>[]> GetLatestSessionsAsync(string

return sessions.ToArray();
}


}

}

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Azure;
using Azure.Data.Tables;

namespace FireCore.Services.Contracts.SessionHandler.AzureTableSessionStorage
{

public class SQL_SESSION_ENTITY : ITableEntity
{
public string RowKey { get; set; } = default!;
Expand Down
Loading