Add Event For When A Guest User Joins
This commit is contained in:
parent
ad5345512a
commit
846a477587
13
QtCNETAPI/Events/GuestUserJoinEventArgs.cs
Normal file
13
QtCNETAPI/Events/GuestUserJoinEventArgs.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QtCNETAPI.Events
|
||||
{
|
||||
public class GuestUserJoinEventArgs : EventArgs
|
||||
{
|
||||
public required string Username { get; set; }
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ namespace QtCNETAPI.Services.GatewayService
|
||||
|
||||
public event EventHandler OnRoomMessageReceived;
|
||||
public event EventHandler OnRoomUserListReceived;
|
||||
public event EventHandler OnGuestUserJoin;
|
||||
public event EventHandler OnRefreshUserListsReceived;
|
||||
public event EventHandler OnRefreshRoomListReceived;
|
||||
public event EventHandler OnRefreshContactsListReceived;
|
||||
@ -58,6 +59,7 @@ namespace QtCNETAPI.Services.GatewayService
|
||||
HubConnection.On("RefreshContactsList", () => OnRefreshContactsListReceived?.Invoke(this, EventArgs.Empty));
|
||||
HubConnection.On<ServerConfig>("ReceiveServerConfig", (serverConfig) => OnServerConfigReceived?.Invoke(this, new ServerConfigEventArgs { ServerConfig = serverConfig }));
|
||||
HubConnection.On<List<User>>("RoomUserList", (userList) => OnRoomUserListReceived?.Invoke(this, new RoomListEventArgs { UserList = userList }));
|
||||
HubConnection.On<string>("GuestJoin", (username) => OnGuestUserJoin?.Invoke(this, new GuestUserJoinEventArgs { Username = username }));
|
||||
|
||||
HubConnection.Closed += HubConnection_Closed;
|
||||
HubConnection.Reconnecting += HubConnection_Reconnecting;
|
||||
|
@ -104,6 +104,11 @@ namespace QtCNETAPI.Services.GatewayService
|
||||
/// </summary>
|
||||
public event EventHandler OnRoomUserListReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Fires When A Guest User Joins Your Room
|
||||
/// </summary>
|
||||
public event EventHandler OnGuestUserJoin;
|
||||
|
||||
/// <summary>
|
||||
/// When A Client Function/Event Is Received, This Event Fires
|
||||
/// </summary>
|
||||
|
@ -33,6 +33,7 @@ namespace qtc_net_client_2.Forms
|
||||
// subscribe to server message event
|
||||
_gatewayService.OnRoomMessageReceived += _gatewayService_OnServerMessageReceived;
|
||||
_gatewayService.OnRoomUserListReceived += _gatewayService_OnRoomUserListReceived;
|
||||
_gatewayService.OnGuestUserJoin += _gatewayService_OnGuestUserJoin;
|
||||
|
||||
if (_gatewayService.CurrentRoom != null) { Text = $"QtC.NET Client - Chat Room - {_gatewayService.CurrentRoom.Name}"; lblRoomName.Text = _gatewayService.CurrentRoom.Name; }
|
||||
else if (_gatewayService.InLobby) { Text = $"QtC.NET Client - Chat Room - Lobby"; lblRoomName.Text = "Lobby"; }
|
||||
@ -126,6 +127,12 @@ namespace qtc_net_client_2.Forms
|
||||
lvUserList.BeginInvoke(delegate () { lvUserList.Items.Add(user.Username, user.Status); });
|
||||
}
|
||||
}
|
||||
private void _gatewayService_OnGuestUserJoin(object? sender, EventArgs e)
|
||||
{
|
||||
var args = (GuestUserJoinEventArgs)e;
|
||||
AddMessage($"[SERVER] Guest User {args.Username} Has Joined {_gatewayService.CurrentRoom?.Name}");
|
||||
}
|
||||
|
||||
|
||||
private void AddMessage(string message)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user