Add PROTOCOL_ADDFRIEND and enable add friend request
This commit is contained in:
@@ -173,7 +173,9 @@ namespace BrewMonster.Network
|
||||
|
||||
// Subscribe to unexpected disconnects
|
||||
_gameSession.Disconnected += OnUnexpectedDisconnect;
|
||||
|
||||
_gameSession.FriendRequestReceived += OnFriendRequestReceived;
|
||||
_gameSession.AddFriendResultReceived += OnAddFriendResultReceived;
|
||||
|
||||
_isInitialized = true;
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
@@ -184,6 +186,8 @@ namespace BrewMonster.Network
|
||||
// Tell LoginScene what to show next.
|
||||
LogoutFlowState.NextLoginEntry = entryTarget;
|
||||
_gameSession.Disconnected -= OnUnexpectedDisconnect;
|
||||
_gameSession.FriendRequestReceived -= OnFriendRequestReceived;
|
||||
_gameSession.AddFriendResultReceived -= OnAddFriendResultReceived;
|
||||
EC_ManMessageMono.Instance.CECNPCMan.Release();
|
||||
|
||||
if (clearSavedCreds)
|
||||
@@ -619,6 +623,16 @@ namespace BrewMonster.Network
|
||||
{
|
||||
Instance._gameSession.c2s_SendCmdDuelReply(accept, idInviter);
|
||||
}
|
||||
/// <summary>Send PROTOCOL_ADDFRIEND(202). Port of CECGameSession::friend_Add.</summary>
|
||||
public static void Friend_Add(int idPlayer, string name)
|
||||
{
|
||||
Instance._gameSession.Friend_Add(idPlayer, name ?? "");
|
||||
}
|
||||
/// <summary>Send PROTOCOL_GETFRIENDS(206). Port of CECGameSession::friend_GetList().</summary>
|
||||
public static void Friend_GetList()
|
||||
{
|
||||
Instance._gameSession.Friend_GetList();
|
||||
}
|
||||
public static void c2s_CmdTeamKickMember(int idMember)
|
||||
{
|
||||
Instance._gameSession.c2s_SendCmdTeamKickMember(idMember);
|
||||
@@ -694,6 +708,25 @@ namespace BrewMonster.Network
|
||||
/// <summary>
|
||||
/// Handles unexpected server disconnections. Shows a message box and returns to login.
|
||||
/// </summary>
|
||||
private void OnFriendRequestReceived(int srcroleid, string askerName)
|
||||
{
|
||||
string name = string.IsNullOrEmpty(askerName) ? ("Player " + srcroleid) : askerName;
|
||||
CECUIManager.Instance?.ShowMessageBox(
|
||||
title: "Friend Request",
|
||||
message: $"{name} wants to add you as a friend.",
|
||||
messageBoxType: MessageBoxType.BothYesNoButton,
|
||||
onClickedYes: () => { /* TODO: accept and call friend_AddResponse */ },
|
||||
onClickedNo: () => { /* TODO: refuse */ });
|
||||
}
|
||||
|
||||
private void OnAddFriendResultReceived(byte retcode, string message)
|
||||
{
|
||||
CECUIManager.Instance?.ShowMessageBox(
|
||||
title: retcode == 0 ? "Friend added" : "Add friend failed",
|
||||
message: message,
|
||||
messageBoxType: MessageBoxType.YesButton);
|
||||
}
|
||||
|
||||
private void OnUnexpectedDisconnect()
|
||||
{
|
||||
// If this was an intentional disconnect (logout), skip UI
|
||||
|
||||
Reference in New Issue
Block a user