Squirrowse/Squirrowse.Service/Hubs/StreamManager.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2019-11-05 17:00:36 +01:00
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Squirrowse.Core.Models;
namespace Squirrowse.Service.Hubs
{
public class StreamManager : IStreamManager
{
private readonly List<User> _users = new List<User>(); //temporary
2019-11-06 17:02:06 +01:00
public Task AddUser(string connectionId, string userName,ConnectionType type)
2019-11-05 17:00:36 +01:00
{
2019-11-06 17:02:06 +01:00
_users.Add(new User(connectionId, userName,type));
2019-11-05 17:00:36 +01:00
return Task.CompletedTask;
}
public Task RemoveUserbyConnectionId(string connectionId)
{
_users.Remove(_users.First(user => user.ConnectionId == connectionId));
return Task.CompletedTask;
}
public Task RemoveUserByUserName(string userName)
{
_users.RemoveAll(user => user.AgentName == userName);
return Task.CompletedTask;
}
2019-11-06 17:02:06 +01:00
public IEnumerable<User> getServerSideUsers()
{
return _users.Where(user => user.UserType == ConnectionType.Server);
}
2019-11-05 17:00:36 +01:00
public bool CheckUser(string userName)
{
return _users.Any(user => user.AgentName == userName);
}
}
}