mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
51 lines
1.4 KiB
C#
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;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
} |