# Class ChatService | EchoHub Documentation

# Class ChatService

Namespace
  EchoHub.Server.Services

Assembly
  EchoHub.Server.dll

    public class ChatService : IChatService

Inheritance
  object
  ChatService

Implements
  IChatService

Inherited Members
  object.GetType()
  object.MemberwiseClone()
  object.ToString()
  object.Equals(object)
  object.Equals(object, object)
  object.ReferenceEquals(object, object)
  object.GetHashCode()

## Constructors

### ChatService(IServiceScopeFactory, PresenceTracker, IEnumerable<IChatBroadcaster>, LinkEmbedService, IMessageEncryptionService, IChannelService, FileStorageService, SpamGuard, ServerLogsService, ServerStatsCollector, ILogger<ChatService>)

    public ChatService(IServiceScopeFactory scopeFactory, PresenceTracker presenceTracker, IEnumerable<IChatBroadcaster> broadcasters, LinkEmbedService embedService, IMessageEncryptionService encryption, IChannelService channelService, FileStorageService fileStorage, SpamGuard spamGuard, ServerLogsService serverLogs, ServerStatsCollector statsCollector, ILogger<ChatService> logger)

#### Parameters

`scopeFactory` IServiceScopeFactory
`presenceTracker` PresenceTracker
`broadcasters` IEnumerable<IChatBroadcaster>
`embedService` LinkEmbedService
`encryption` IMessageEncryptionService
`channelService` IChannelService
`fileStorage` FileStorageService
`spamGuard` SpamGuard
`serverLogs` ServerLogsService
`statsCollector` ServerStatsCollector
`logger` ILogger<ChatService>

## Methods

### BroadcastChannelDeletedAsync(string)

    public Task BroadcastChannelDeletedAsync(string channelName)

#### Parameters

`channelName` string

#### Returns

Task

### BroadcastChannelUpdatedAsync(ChannelDto, string?)

    public Task BroadcastChannelUpdatedAsync(ChannelDto channel, string? channelName = null)

#### Parameters

`channel` ChannelDto
`channelName` string

#### Returns

Task

### BroadcastMessageAsync(string, MessageDto)

    public Task BroadcastMessageAsync(string channelName, MessageDto message)

#### Parameters

`channelName` string
`message` MessageDto

#### Returns

Task

### GetChannelHistoryAsync(string, int, int)

    public Task<List<MessageDto>> GetChannelHistoryAsync(string channelName, int count, int offset = 0)

#### Parameters

`channelName` string
`count` int
`offset` int

#### Returns

Task<List<MessageDto>>

### GetChannelsForUserAsync(string)

    public Task<List<string>> GetChannelsForUserAsync(string username)

#### Parameters

`username` string

#### Returns

Task<List<string>>

### GetOnlineUsersAsync(string)

    public Task<List<UserPresenceDto>> GetOnlineUsersAsync(string channelName)

#### Parameters

`channelName` string

#### Returns

Task<List<UserPresenceDto>>

### JoinChannelAsync(string, Guid, string, string, string?)

    public Task<(List<MessageDto> History, string? Error, bool PasswordRequired)> JoinChannelAsync(string connectionId, Guid userId, string username, string channelName, string? password = null)

#### Parameters

`connectionId` string
`userId` Guid
`username` string
`channelName` string
`password` string

#### Returns

Task<(List<MessageDto> History, string Error, bool PasswordRequired)>

### LeaveChannelAsync(string, string, string)

    public Task LeaveChannelAsync(string connectionId, string username, string channelName)

#### Parameters

`connectionId` string
`username` string
`channelName` string

#### Returns

Task

### SendMessageAsync(Guid, string, string, string, string?, Guid?)

    public Task<string?> SendMessageAsync(Guid userId, string username, string channelName, string content, string? originConnectionId = null, Guid? replyToMessageId = null)

#### Parameters

`userId` Guid
`username` string
`channelName` string
`content` string
`originConnectionId` string
`replyToMessageId` Guid?

#### Returns

Task<string>

### UpdateStatusAsync(Guid, string, UserStatus, string?)

    public Task<string?> UpdateStatusAsync(Guid userId, string username, UserStatus status, string? statusMessage)

#### Parameters

`userId` Guid
`username` string
`status` UserStatus
`statusMessage` string

#### Returns

Task<string>

### UserConnectedAsync(string, Guid, string)

    public Task UserConnectedAsync(string connectionId, Guid userId, string username)

#### Parameters

`connectionId` string
`userId` Guid
`username` string

#### Returns

Task

### UserDisconnectedAsync(string)

    public Task<string?> UserDisconnectedAsync(string connectionId)

#### Parameters

`connectionId` string

#### Returns

Task<string>