PC-20230316NUNE\Administrator d67032e1de 提交新概念 Tile从服务器
2024-08-31 15:35:12 +08:00

51 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JNGame.Network;
using Plugins.JNGame.Network;
namespace AppGame.Systems.CServer
{
public partial class JNGServer : JNTCPServer
{
//客户端绑定的Id
private Dictionary<string, int> ids = new();
//客户端角色
private Dictionary<string, JNGClientRole> _roles = new();
public Dictionary<string, JNGClientRole> Roles => _roles;
public void OnInit_Game()
{
AddListener((int)GActionEnum.BindClientID,OnBindClientID);
AddListener((int)GActionEnum.BindClientRole,OnBindClientRole);
}
/// <summary>
/// 绑定客户端Id
/// </summary>
/// <param name="obj"></param>
/// <exception cref="NotImplementedException"></exception>
private void OnBindClientID(JNServerParam args)
{
var message = GBindClientID.Parser.ParseFrom(args.Message);
ids[args.Client] = message.ClientId;
}
/// <summary>
/// 绑定客户端角色
/// </summary>
private void OnBindClientRole(JNServerParam args)
{
var message = GBindClientRole.Parser.ParseFrom(args.Message);
_roles[args.Client] = (JNGClientRole)message.Role;
}
}
}