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 ids = new(); //客户端角色 private Dictionary _roles = new(); public Dictionary Roles => _roles; public void OnInit_Game() { AddListener((int)GActionEnum.BindClientID,OnBindClientID); AddListener((int)GActionEnum.BindClientRole,OnBindClientRole); } /// /// 绑定客户端Id /// /// /// private void OnBindClientID(JNServerParam args) { var message = GBindClientID.Parser.ParseFrom(args.Message); ids[args.Client] = message.ClientId; } /// /// 绑定客户端角色 /// private void OnBindClientRole(JNServerParam args) { var message = GBindClientRole.Parser.ParseFrom(args.Message); _roles[args.Client] = (JNGClientRole)message.Role; } } }