エンジンクラス
MessagingService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
PublishAsync(topic: string,message: Variant):() |
SubscribeAsync(topic: string,callback: function):RBXScriptConnection |
APIリファレンス
方法
PublishAsync
SubscribeAsync
コードサンプル
クロスサーバーメッセージへのサブスクリプション
local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")
local function onPlayerAdded(player)
-- トピックにサブスクライブ
local topic = "player-" .. player.UserId
local connection = MessagingService:SubscribeAsync(topic, function(message)
print("Received message for", player.Name, message.Data)
end)
player.AncestryChanged:Connect(function()
-- トピックからサブスクリプションを解除
connection:Disconnect()
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)