public void Disconnect(IUser user, UserDisconnectReason reason = UserDisconnectReason.Unknown) { if (user == null) { return; } Dispatcher.DispatchEvent(this, new UserDisconnectEvent(user, reason)); }
public ChannelUserLeaveEvent(IChannel channel, IUser user, UserDisconnectReason reason) : base( channel ?? throw new ArgumentNullException(nameof(channel)), user ?? throw new ArgumentNullException(nameof(user)) ) { Reason = reason; }
public void LeaveChannel(IChannel channel, IUser user, UserDisconnectReason reason = UserDisconnectReason.Unknown) { if (channel == null) { throw new ArgumentNullException(nameof(channel)); } if (user == null) { throw new ArgumentNullException(nameof(user)); } if (HasUser(channel, user)) { Dispatcher.DispatchEvent(this, new ChannelUserLeaveEvent(channel, user, reason)); } }
// should this be moved to UserManager? public void BanUser( IUser user, TimeSpan duration, UserDisconnectReason reason = UserDisconnectReason.Kicked, bool isPermanent = false, IUser modUser = null, string textReason = null ) { ForceDisconnectPacket packet; if (duration != TimeSpan.Zero || isPermanent) { if (string.IsNullOrWhiteSpace(textReason)) { textReason = reason switch { UserDisconnectReason.Kicked => @"User was banned.", UserDisconnectReason.Flood => @"User was kicked for flood protection.", _ => @"Unknown reason given.", } } ; DataProvider.BanClient.CreateBan(user.UserId, modUser?.UserId ?? -1, isPermanent, duration, textReason); packet = new ForceDisconnectPacket(ForceDisconnectReason.Banned, duration, isPermanent); } else { packet = new ForceDisconnectPacket(ForceDisconnectReason.Kicked); } // handle in users //user.SendPacket(packet); // channel users ChannelUsers.GetChannels(user, c => { foreach (IChannel chan in c) { ChannelUsers.LeaveChannel(chan, user, reason); } }); // a disconnect with Flood, Kicked or Banned should probably cause this // maybe forced disconnects should be their own event? Users.Disconnect(user, reason); }
public void HandleLeave(SockChatChannel chan, SockChatUser user, string type = Constants.LEAVE_NORMAL) { UserDisconnectReason reason = UserDisconnectReason.Leave; switch (type) { case Constants.LEAVE_TIMEOUT: reason = UserDisconnectReason.TimeOut; break; case Constants.LEAVE_KICK: reason = UserDisconnectReason.Kicked; break; case Constants.LEAVE_FLOOD: reason = UserDisconnectReason.Flood; break; } chan.Send(new UserDisconnectPacket(DateTimeOffset.Now, user, reason)); }
public UserDisconnectPacket(DateTimeOffset disconnected, SockChatUser user, UserDisconnectReason reason) { Disconnected = disconnected; User = user ?? throw new ArgumentNullException(nameof(user)); Reason = reason; }
public ServerPartCommand(IChannel channel, IUser user, UserDisconnectReason reason) { Channel = channel ?? throw new ArgumentNullException(nameof(channel)); Sender = user ?? throw new ArgumentNullException(nameof(user)); Reason = reason; }
public UserDisconnectEvent(IUser user, UserDisconnectReason reason) : base(null, user ?? throw new ArgumentNullException(nameof(user))) { Reason = reason; }
public void UserLeave(IChannel chan, IUser user, UserDisconnectReason reason = UserDisconnectReason.Leave) { // handle in channelusers //chan.SendPacket(new UserDisconnectPacket(DateTimeOffset.Now, user, reason)); }
public ChannelUserLeaveEvent(IUser user, IChannel channel, UserDisconnectReason reason) : base(user, channel) { Reason = reason; }