mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] 接入ET8服务端
[+] 接入ET8服务端
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
|
||||
namespace ET.Server
|
||||
{
|
||||
[MessageHandler(SceneType.Realm)]
|
||||
public class C2R_LoginHandler : MessageHandler<C2R_Login, R2C_Login>
|
||||
{
|
||||
protected override async ETTask Run(Session session, C2R_Login request, R2C_Login response)
|
||||
{
|
||||
// 随机分配一个Gate
|
||||
StartSceneConfig config = RealmGateAddressHelper.GetGate(session.Zone(), request.Account);
|
||||
Log.Debug($"gate address: {config}");
|
||||
|
||||
// 向gate请求一个key,客户端可以拿着这个key连接gate
|
||||
G2R_GetLoginKey g2RGetLoginKey = (G2R_GetLoginKey) await session.Fiber().Root.GetComponent<ActorSenderComponent>().Call(
|
||||
config.ActorId, new R2G_GetLoginKey() {Account = request.Account});
|
||||
|
||||
response.Address = config.InnerIPPort.ToString();
|
||||
response.Key = g2RGetLoginKey.Key;
|
||||
response.GateId = g2RGetLoginKey.GateId;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e499cce63c705be489700108cfb56ef2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,22 @@
|
||||
using System.Net;
|
||||
|
||||
namespace ET.Server
|
||||
{
|
||||
[Invoke((long)SceneType.Realm)]
|
||||
public class FiberInit_Realm: AInvokeHandler<FiberInit, ETTask>
|
||||
{
|
||||
public override async ETTask Handle(FiberInit fiberInit)
|
||||
{
|
||||
Scene root = fiberInit.Fiber.Root;
|
||||
root.AddComponent<MailBoxComponent, MailBoxType>(MailBoxType.UnOrderedMessage);
|
||||
root.AddComponent<TimerComponent>();
|
||||
root.AddComponent<CoroutineLockComponent>();
|
||||
root.AddComponent<ActorInnerComponent>();
|
||||
root.AddComponent<ActorSenderComponent>();
|
||||
StartSceneConfig startSceneConfig = StartSceneConfigCategory.Instance.Get(root.Fiber.Id);
|
||||
root.AddComponent<NetServerComponent, IPEndPoint>(startSceneConfig.InnerIPPort);
|
||||
|
||||
await ETTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f15a025727328543b751e037d5c8657
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace ET.Server
|
||||
{
|
||||
public static partial class RealmGateAddressHelper
|
||||
{
|
||||
public static StartSceneConfig GetGate(int zone, string account)
|
||||
{
|
||||
long hash = account.GetLongHashCode();
|
||||
|
||||
List<StartSceneConfig> zoneGates = StartSceneConfigCategory.Instance.Gates[zone];
|
||||
|
||||
return zoneGates[(int)(hash % zoneGates.Count)];
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb7be8a992c4c8e4f9c54c0543834360
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user