广播聊天
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Platform.Net;
|
||||
|
||||
namespace NB.Chat;
|
||||
@@ -12,10 +13,11 @@ public static class ChatSceneHelper
|
||||
/// <param name="message"></param>
|
||||
public static void Broadcast(Scene scene, string message)
|
||||
{
|
||||
Log.Info("广播消息===");
|
||||
//发送给所有Gate服务器,让Gate转发给其他客户端
|
||||
var gateConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate);
|
||||
|
||||
var sendMessage = new Chat2C_Message()
|
||||
var sendMessage = new Chat2G_ChatMessage()
|
||||
{
|
||||
Message = message
|
||||
};
|
||||
@@ -26,4 +28,34 @@ public static class ChatSceneHelper
|
||||
networkMessagingComponent.SendInnerRoute(config.RouteId, sendMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static async FTask<long> Online(Scene scene, long accountID, long gateRuntimeId)
|
||||
{
|
||||
var gameSceneConfig = GetSceneConfig();
|
||||
var gameRouteId = gameSceneConfig.RouteId;
|
||||
//连接到游戏中心服
|
||||
var gameResponse = (Chat2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
|
||||
gameRouteId, new G2Chat_EnterRequest()
|
||||
{
|
||||
AccountId = accountID,
|
||||
GateRouteId = gateRuntimeId
|
||||
});
|
||||
|
||||
if (gameResponse.ErrorCode != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return gameResponse.RoleRouteId;
|
||||
}
|
||||
|
||||
private static SceneConfig GetSceneConfig()
|
||||
{
|
||||
var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Chat);
|
||||
|
||||
return gameSceneConfigs.First();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user