summaryrefslogtreecommitdiff
path: root/DSACore/Hubs
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-09-29 20:22:11 +0200
committerTrueDoctor <d-kobert@web.de>2018-09-29 20:22:11 +0200
commit33dc613fffad69c1c608e21eac6fcd3f2954ead8 (patch)
treea30876c8effdb19472873539afdbb232e8081bb8 /DSACore/Hubs
parent6caf0178d0132a9e70144094957a8a6dcee666e5 (diff)
added all data classes
Diffstat (limited to 'DSACore/Hubs')
-rw-r--r--DSACore/Hubs/ChatHub.cs23
1 files changed, 17 insertions, 6 deletions
diff --git a/DSACore/Hubs/ChatHub.cs b/DSACore/Hubs/ChatHub.cs
index de8705e..6335183 100644
--- a/DSACore/Hubs/ChatHub.cs
+++ b/DSACore/Hubs/ChatHub.cs
@@ -19,8 +19,18 @@ namespace DSACore.Hubs
var args = message.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
var ident = args.First().Replace("!", "");
if(args.Count>0){args.RemoveAt(0);}
+
+ string group;
+ try
+ {
+ group = getGroup(Context.ConnectionId).Name;
+ await SendToGroup(group, user, Commands.CommandHandler.ExecuteCommand(new Command { CharId = 0, CmdIdentifier = ident, CmdTexts = args, Name = user }));
+ }
+ catch(InvalidOperationException e)
+ {
+ await Clients.Caller.SendCoreAsync("ReceiveMessage", new[] {"Nutzer ist in keiner Gruppe. Erst joinen!"});
+ }
- await SendToGroup(getGroup(Context.ConnectionId).Name, user, Commands.CommandHandler.ExecuteCommand(new Command{CharId = 0,CmdIdentifier = ident, CmdTexts = args, Name = user}));
}
private Task SendToGroup(string group, string user, string message)
@@ -35,19 +45,20 @@ namespace DSACore.Hubs
public async Task GetGroups()
{
- await Clients.Caller.SendCoreAsync("ListGroups", new object[] { Groups });
- throw new NotImplementedException("add database call to get groups");
+ await Clients.Caller.SendCoreAsync("ListGroups", new object[] { DSAGroups });
+ //throw new NotImplementedException("add database call to get groups");
}
public async Task AddGroup(string group, string password)
{
- await Clients.Caller.SendCoreAsync("ListGroups", new object[] { Groups });
- throw new NotImplementedException("add database call to add groups");
+ DSAGroups.Add(new Group{Name = group, Password = password});
+ Clients.Caller.SendCoreAsync("ReceiveMessage", new[] {$"group {group} sucessfully added"});
+ //throw new NotImplementedException("add database call to add groups");
}
public async Task Login(string group, string user, string password)
{
- if (password == "valid")
+ if (password == DSAGroups.First(x=>x.Name == group).Password)
{
DSAGroups.First(x=>x.Name.Equals(group)).Users.Add(new User{ConnectionId = Context.ConnectionId, Name = user});
await Groups.AddToGroupAsync(Context.ConnectionId, group);