internal void OnChatStarted(ChatInfo chatInfo) { SearchRequests.Pop(); ActiveChats.Add(chatInfo); ChatStarted?.Invoke(this, new ChatEventArgs(ChatState.Started, chatInfo)); }
public async Task StartNewChatAsync() { const string ip = "randomchat.sloppy.zone"; _hubConnection = new HubConnectionBuilder() .WithUrl($"https://{ip}/chat", HttpTransportType.ServerSentEvents).Build(); _hubConnection.On("StartChat", () => ChatStarted?.Invoke(this, EventArgs.Empty)); _hubConnection.On <string>("Message", (message) => NewMessage?.Invoke(this, new NewMessageEventArgs(message))); _hubConnection.On("ClientDisconnected", () => ChatStopped?.Invoke(this, EventArgs.Empty)); await _hubConnection.StartAsync().ConfigureAwait(false); }