NoSugarNet/NoSugarNet.ServerCore/Manager/LoginManager.cs

46 lines
1.7 KiB
C#
Raw Normal View History

2024-01-16 18:04:15 +08:00
using AxibugProtobuf;
2024-01-22 15:08:43 +08:00
using NoSugarNet.ServerCore.Common;
2024-01-16 18:04:15 +08:00
using ServerCore.Common;
using ServerCore.NetWork;
using System.Net.Sockets;
namespace ServerCore.Manager
{
public class LoginManager
{
public LoginManager()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdLogin, UserLogin);
}
public void UserLogin(Socket _socket, byte[] reqData)
{
ServerManager.g_Log.Debug("收到新的登录请求");
Protobuf_Login msg = ProtoBufHelper.DeSerizlize<Protobuf_Login>(reqData);
ClientInfo cinfo = ServerManager.g_ClientMgr.JoinNewClient(msg, _socket);
byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_Login_RESP()
{
Status = LoginResultStatus.Ok,
RegDate = "",
LastLoginDate = "",
2024-06-25 18:23:08 +08:00
Token = "",
UID = cinfo.UID
2024-01-16 18:04:15 +08:00
});
ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdLogin, (int)ErrorCode.ErrorOk, respData);
2024-01-22 11:57:17 +08:00
Protobuf_Cfgs cfgsSP = new Protobuf_Cfgs();
2024-01-25 17:17:16 +08:00
byte[] keys = Config.cfgs.Keys.ToArray();
for (int i = 0; i < Config.cfgs.Count; i++)
2024-01-22 15:08:43 +08:00
{
2024-01-25 17:17:16 +08:00
TunnelClientData cfg = Config.cfgs[keys[i]];
2024-01-22 15:08:43 +08:00
cfgsSP.Cfgs.Add(new Protobuf_Cfgs_Single() { TunnelID = cfg.TunnelId, Port = cfg.ClientLocalPort });
}
2024-01-25 17:17:16 +08:00
cfgsSP.CompressAdapterType = (int)Config.compressAdapterType;
2024-01-22 11:57:17 +08:00
byte[] respDataCfg = ProtoBufHelper.Serizlize(cfgsSP);
2024-06-25 18:23:08 +08:00
ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdServerCfgs, (int)ErrorCode.ErrorOk, respDataCfg);
2024-01-16 18:04:15 +08:00
}
}
}