示例#1
0
文件: Client.cs 项目: Ciastex/Ghost
        internal void OnChatStarted(ChatInfo chatInfo)
        {
            SearchRequests.Pop();
            ActiveChats.Add(chatInfo);

            ChatStarted?.Invoke(this, new ChatEventArgs(ChatState.Started, chatInfo));
        }
示例#2
0
        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);
        }