Messaging Service
概要
方法
PublishAsync(topic: string,message: Variant):() |
SubscribeAsync(topic: string,callback: function):RBXScriptConnection |
APIリファレンス
方法
Publish Async
Subscribe Async
コードサンプル
クロスサーバーメッセージの購読
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)