Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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);
                }
            }
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
 public HubGroup SetGroup(string hubName, HubGroup group)
 {
     return(SetGroup(hubName, group.Name, group.Realname, group.Note));
 }
Esempio n. 7
0
 public async Task SendGameAsync(HubGroup group, string id)
 {
     await _context.Clients.Group($"{group.ToString()}/{id}").SendAsync($"{group.ToString()}/{id}",
                                                                        GetAvailable());
 }
Esempio n. 8
0
 public async Task SendAvailableAsync(HubGroup group, string method)
 {
     await _context.Clients.Group(group.ToString()).SendAsync(method, GetAvailable());
 }
Esempio n. 9
0
 public override Task AddSessionAsync(HubCallerContext context, HubGroup group)
 {
     Create(context);
     return(base.AddSessionAsync(context, group));
 }
Esempio n. 10
0
 public virtual async Task AddSessionAsync(HubCallerContext context, HubGroup group, string subGroup)
 {
     await _context.Groups.AddToGroupAsync(context.ConnectionId, $"{group.ToString()}/{subGroup}");
 }