private bool Login(User user, string password, bool invited) { if (InviteOnly && !invited) { throw new Exception("This channel is invite only!"); } lock (m_users) { foreach (var u in m_users) { if (u.Name.ToLower().Equals(user.Name.ToLower())) { throw new Exception("User already in channel"); } } if (Password.Equals(password)) { m_timeout.Stop(); m_users.Add(user); HubGroup.UpdateUsers(Users.AsString()); return(true); } } return(false); }
public void Send(User user, string text) { if (string.IsNullOrEmpty(text)) { return; } Message message = new Message(user, text); m_messages.Enqueue(message); HubGroup.Send(message.User.Name, message.Text, message.TimestampMs); if (m_messages.Count > MaxHistory) { m_messages.TryDequeue(out Message tmp_message); } if (text.StartsWith("!")) { m_cmdparser.Exec(text); } else { Message?.Invoke(this, message); } }
public HubGroup DeleteGroup(string hubName, string name) { var requestData = new SoftEtherParameterCollection { { "HubName", hubName }, { "Name", name } }; var rawData = _softEther.CallMethod("DeleteGroup", requestData); return(HubGroup.Deserialize(rawData)); }
public void Logout(User user) { lock (m_users) { m_users.Remove(user); HubGroup.UpdateUsers(Users.AsString()); if (m_users.Count == 0) { m_timeout.Start(KeepAliveTimeout); } } }
public HubGroup SetGroup(string hubName, string name, string realName, string note) { var requestData = new SoftEtherParameterCollection { { "HubName", hubName }, { "Name", name }, { "Realname", SoftEtherValueType.UnicodeString, realName }, { "Note", SoftEtherValueType.UnicodeString, note } }; var rawData = _softEther.CallMethod("SetGroup", requestData); return(HubGroup.Deserialize(rawData)); }
public HubGroup SetGroup(string hubName, HubGroup group) { return(SetGroup(hubName, group.Name, group.Realname, group.Note)); }
public async Task SendGameAsync(HubGroup group, string id) { await _context.Clients.Group($"{group.ToString()}/{id}").SendAsync($"{group.ToString()}/{id}", GetAvailable()); }
public async Task SendAvailableAsync(HubGroup group, string method) { await _context.Clients.Group(group.ToString()).SendAsync(method, GetAvailable()); }
public override Task AddSessionAsync(HubCallerContext context, HubGroup group) { Create(context); return(base.AddSessionAsync(context, group)); }
public virtual async Task AddSessionAsync(HubCallerContext context, HubGroup group, string subGroup) { await _context.Groups.AddToGroupAsync(context.ConnectionId, $"{group.ToString()}/{subGroup}"); }