Update friend delete, handle server sending
This commit is contained in:
@@ -68,6 +68,7 @@ namespace CSNetwork
|
||||
|
||||
/// <summary>Raised when server sends PROTOCOL_GETFRIENDS_RE(207).</summary>
|
||||
public event Action<getfriends_re> FriendListReceived;
|
||||
public event Action<delfriend_re> FriendDeletedReceived;
|
||||
|
||||
/// <summary>Raised when server sends PROTOCOL_FRIENDSTATUS(214). Args: roleid, status.</summary>
|
||||
public event Action<int, byte> FriendStatusChanged;
|
||||
@@ -633,12 +634,26 @@ namespace CSNetwork
|
||||
OnFriendStatus((friendstatus)protocol);
|
||||
break;
|
||||
|
||||
case ProtocolType.PROTOCOL_DELFRIEND_RE:
|
||||
OnDelFriendRe((delfriend_re)protocol);
|
||||
break;
|
||||
|
||||
default:
|
||||
_logger.Log(LogType.Warning, $"Received unhandled protocol type: {protocol.GetPType()}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDelFriendRe(delfriend_re p)
|
||||
{
|
||||
PostToUnityContext(() =>
|
||||
{
|
||||
FriendDeletedReceived?.Invoke(p);
|
||||
if (p != null && p.retcode == 0)
|
||||
Friend_GetList();
|
||||
});
|
||||
}
|
||||
|
||||
private void HandlePlayerLogout(playerlogout protocol)
|
||||
{
|
||||
// old code of HUNGDK
|
||||
@@ -2538,7 +2553,6 @@ namespace CSNetwork
|
||||
p.Friendid = friendId;
|
||||
p.Localsid = (int)_localsid;
|
||||
SendProtocol(p);
|
||||
Friend_GetList();
|
||||
}
|
||||
|
||||
public void c2s_SendCmdTeamKickMember(int idMember)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace CSNetwork.Protocols
|
||||
{
|
||||
/// <summary>PROTOCOL_DELFRIEND_RE(213). Delete friend response.</summary>
|
||||
public class delfriend_re : Protocol
|
||||
{
|
||||
public byte retcode { get; set; }
|
||||
public int roleid { get; set; }
|
||||
public int friendid { get; set; }
|
||||
public uint srclsid { get; set; }
|
||||
|
||||
public delfriend_re() : base(ProtocolType.PROTOCOL_DELFRIEND_RE) { }
|
||||
|
||||
public override Protocol Clone() => new delfriend_re
|
||||
{
|
||||
retcode = retcode,
|
||||
roleid = roleid,
|
||||
friendid = friendid,
|
||||
srclsid = srclsid
|
||||
};
|
||||
|
||||
public override void Marshal(OctetsStream os)
|
||||
{
|
||||
os.Write(retcode);
|
||||
os.Write(roleid);
|
||||
os.Write(friendid);
|
||||
os.Write(srclsid);
|
||||
}
|
||||
|
||||
public override void Unmarshal(OctetsStream os)
|
||||
{
|
||||
retcode = os.ReadByte();
|
||||
roleid = os.ReadInt32();
|
||||
friendid = os.ReadInt32();
|
||||
srclsid = os.ReadUInt32();
|
||||
}
|
||||
|
||||
public override int PriorPolicy() => 1;
|
||||
|
||||
public override bool SizePolicy(int size) => size <= 32;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c7fd991e4b531e48856e282ffee5cf2
|
||||
@@ -130,12 +130,7 @@ namespace BrewMonster
|
||||
if (m_deleteBtn != null)
|
||||
{
|
||||
m_deleteBtn.onClick.RemoveAllListeners();
|
||||
m_deleteBtn.onClick.AddListener(() =>
|
||||
{
|
||||
if (_session == null) return;
|
||||
if (_selectedFriendId <= 0) return;
|
||||
_session.Friend_Del(_selectedFriendId);
|
||||
});
|
||||
m_deleteBtn.onClick.AddListener(OnDeleteFriendClicked);
|
||||
}
|
||||
|
||||
if (m_fuctionBtn != null)
|
||||
@@ -329,6 +324,13 @@ namespace BrewMonster
|
||||
_selectedRowOriginalColor = default;
|
||||
}
|
||||
|
||||
/// <summary>Delete friend: send PROTOCOL_DELFRIEND and wait for server to refresh list.</summary>
|
||||
private void OnDeleteFriendClicked()
|
||||
{
|
||||
if (_session == null || _selectedFriendId <= 0) return;
|
||||
_session.Friend_Del(_selectedFriendId);
|
||||
}
|
||||
|
||||
private void EnsureAddNameInput()
|
||||
{
|
||||
if (_addNameInput != null) return;
|
||||
|
||||
Reference in New Issue
Block a user