72 lines
3.3 KiB
C#
72 lines
3.3 KiB
C#
using Ananta.SDK.Rpc;
|
||
using Ananta.Server.ClientData.Client4229938;
|
||
using Ananta.Server.Handlers;
|
||
using Ananta.Server.Protocol.Client4229938;
|
||
using GameMethods = Ananta.Server.RpcTypes.Client4229938.Methods.Game;
|
||
|
||
namespace Ananta.Server.Handlers.Game;
|
||
|
||
/// <summary>
|
||
/// 手机「拨号」线的两个 C2S 回执(T1-9 的通话记录 / 联系人操作那一半)。
|
||
///
|
||
/// 这两条之前没有任何 handler,客户端 await 的是返回值 ⇒ 走的是中性兜底。兜底的回包也是 0 错误,
|
||
/// 所以表面上"没崩",但 CallPhoneUtils 的回调分支依赖 err == Ok 才继续写本地记录:
|
||
/// AskPhoneAddCallRecord → 成功后 table.insert(CallRecordList) 并抛
|
||
/// ON_CALL_PHONE_ADD_CALL_RECORD_SUCCESS(否则弹服务端错误提示、记录不落本地)
|
||
/// 联系人选项那条更关键:它的 result 直接决定 ShowContactOptionDialog 播 SuccessDialogId 还是
|
||
/// FailDialogId(叫车失败提示 / 好感度对话打不开都出在这)。
|
||
///
|
||
/// 内容侧不需要服务端参与:拨通之后的对话是客户端本地 ShowGeneralDialog(dialogId),
|
||
/// 通讯录与解锁进度都由登录帧下发(RuntimePayloadFactory 的 PhoneContacts / PhoneContactsUnlockAll)。
|
||
/// 所以这里只做两件事 —— 记日志 + 回一个 0 错误空包(与兜底字节一致,不碰客户端既有分支)。
|
||
/// </summary>
|
||
internal sealed partial class GameRouter
|
||
{
|
||
[Handler(MethodId.AskPhoneAddCallRecord, HandlerPacketKind.Invoke)]
|
||
private Task AskPhoneAddCallRecord4229938(Connection conn, UxRpcMessage msg)
|
||
{
|
||
if (!msg.TryGetArgs<GameMethods.AskPhoneAddCallRecord>(out var args) || args is null)
|
||
{
|
||
conn.Log.Warn($"[PHONE-CALL] AskPhoneAddCallRecord undecodable bytes={msg.Body.Length}");
|
||
return conn.ReturnEmptyOkAsync(msg);
|
||
}
|
||
|
||
// 号码回查本地表拿名字,日志里能直接看出拨的是谁(失败就退化成号码,不影响回包)。
|
||
var name = NameOfPhoneNumber(args.phoneNumber);
|
||
conn.Log.Info(
|
||
$"[PHONE-CALL] record spirit={args.spiritId} number={args.phoneNumber} " +
|
||
$"name={name} callType={args.callType}");
|
||
|
||
return conn.ReturnEmptyOkAsync(msg);
|
||
}
|
||
|
||
[Handler(MethodId.AskPhoneContactOptionAction, HandlerPacketKind.Invoke)]
|
||
private Task AskPhoneContactOptionAction4229938(Connection conn, UxRpcMessage msg)
|
||
{
|
||
if (!msg.TryGetArgs<GameMethods.AskPhoneContactOptionAction>(out var args) || args is null)
|
||
{
|
||
conn.Log.Warn($"[PHONE-CALL] AskPhoneContactOptionAction undecodable bytes={msg.Body.Length}");
|
||
return conn.ReturnEmptyOkAsync(msg);
|
||
}
|
||
|
||
conn.Log.Info(
|
||
$"[PHONE-CALL] option spirit={args.spiritId} contactId={args.contactId} " +
|
||
$"optionId={args.contactOptionId}");
|
||
|
||
return conn.ReturnEmptyOkAsync(msg);
|
||
}
|
||
|
||
/// <summary>把号码翻成名字,纯粹为了让日志可读;查不到就返回空串。</summary>
|
||
private static string NameOfPhoneNumber(string phoneNumber)
|
||
{
|
||
if (string.IsNullOrEmpty(phoneNumber))
|
||
return string.Empty;
|
||
|
||
foreach (var contact in PhoneContactCatalog4229938.Contacts)
|
||
if (string.Equals(contact.PhoneNumber, phoneNumber, StringComparison.Ordinal))
|
||
return contact.Name;
|
||
|
||
return string.Empty;
|
||
}
|
||
}
|