Breakroom is now Sinewave Campus. Book a meeting

SChat

客户端网络
在此类中OnChat
  1. 函数
  2. OnChat
  3. JoinChat
  4. GetXMPPName
  5. LeaveChat
  6. GetVoiceZone
  7. JoinVoice
  8. JoinGridVoice
  9. LeaveVoice
成员 8
函数OnChatBind a function to the OnChat event.
函数JoinChatJoin a chat channel.
函数GetXMPPNameGet XMPP name.
函数LeaveChatLeave a chat channel.
函数GetVoiceZoneGet a reference to a voice zone component for the given channel.
函数JoinVoiceJoin a voice chat channel.
函数JoinGridVoiceJoinGridVoice is the same as JoinVoice except with a grid wide parameter. (white-label only)
函数LeaveVoiceLeave a voice chat channel

函数​

OnChat​

void OnChat(Closure callback)
void OnChat(Action< SChatMessage > trackInfoCallback)

Bind a function to the OnChat event. This function will be called every time a new chat message is received on the local channel.

参数

参数类型说明
callbackClosure or Action<SChatMessage>Invoked when a chat message is received

返回值

void

示例

Lua
Space.Network.Chat.OnChat(OnChatFunction)
Lua
--this script takes every new chat message and displays it in a UIText
uiText = Space.Host.GetReference("text").UIText --Add this Text object as reference in Scripting Runtime

OnChatFunction = function(SChatMessage)
uiText.Text = SChatMessage.Sender ..": " .. SChatMessage.Message
end

Space.Network.Chat.OnChat(OnChatFunction)

JoinChat​

void JoinChat(string name)

Join a chat channel.

参数

参数类型说明
namestringChat channel to join

返回值

void

示例

Lua
Space.Network.Chat.JoinChat("Test room")
Lua
--this script will make the player join a chat when entering a trigger collider and leave it when leaving
--[Requires this object to have a "Trigger" collider]

thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar

OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.JoinChat("PrivateChatZone")

end

end

OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.LeaveChat("PrivateChatZone")

end

end


thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)

GetXMPPName​

string GetXMPPName(string name)

Get XMPP name.

参数

参数类型说明
namestringHuman-readable chat name

返回值

string

示例

Lua
Space.Network.Chat.GetXMPPName("Test room")

LeaveChat​

void LeaveChat(string name)

Leave a chat channel.

参数

参数类型说明
namestringChat channel to leave

返回值

void

示例

Lua
Space.Network.Chat.LeaveChat("Test room")
Lua
--this script will make the player join a chat when entering a trigger collider and leave it when leaving
--[Requires this object to have a "Trigger" collider]

thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar

OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.JoinChat("PrivateChatZone")

end

end

OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.LeaveChat("PrivateChatZone")

end

end


thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)

GetVoiceZone​

SVoiceZone GetVoiceZone(string channel)

Get a reference to a voice zone component for the given channel.

参数

参数类型说明
channelstringVoice channel name/handle

返回值

SVoiceZone

示例

Lua
voiceZone = Space.Network.Chat.GetVoiceZone("AChannel")

JoinVoice​

void JoinVoice(string channel, int priority = 5, int spatial = 0)

Join a voice chat channel.

参数

参数类型说明
channelstringVoice channel name/handle
priorityintOptional. Priority, default 5
spatialintOptional. Spatialization flag (0/1), default 0

返回值

void

示例

Lua
Space.Network.Chat.JoinVoice("PrivateVoiceZone")
Lua
--this script will make the player join a voice channel when entering a trigger collider and leave it when leaving
--[Requires this object to have a "Trigger" collider]

thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar

OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.JoinVoice("PrivateVoiceZone")

end

end

OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.LeaveVoice("PrivateVoiceZone")

end

end


thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)

JoinGridVoice​

void JoinGridVoice(string channel, int priority = 5, int spatial = 0)

JoinGridVoice is the same as JoinVoice except with a grid wide parameter. (white-label only)

参数

参数类型说明
channelstringVoice channel name/handle (grid-wide)
priorityintOptional. Priority, default 5
spatialintOptional. Spatialization flag (0/1), default 0

返回值

void

示例

Lua
Space.Network.Chat.JoinGridVoice("PrivateGridVoiceZone")
Lua
--this script will make the player join a Grid voice channel when entering a trigger collider and leave it when leaving
--[Requires this object to have a "Trigger" collider]

thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar

OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.JoinGridVoice("PrivateGridVoiceZone")

end

end

OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.LeaveVoice("PrivateGridVoiceZone")

end

end


thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)

LeaveVoice​

void LeaveVoice(string channel)

Leave a voice chat channel

参数

参数类型说明
channelstringVoice channel to leave

返回值

void

示例

Lua
Space.Network.Chat.LeaveVoice("PrivateVoiceZone")
Lua
--this script will make the player join a voice channel when entering a trigger collider and leave it when leaving
--[Requires this object to have a "Trigger" collider]

thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar

OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.JoinVoice("PrivateVoiceZone")

end

end

OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

Space.Network.Chat.LeaveVoice("PrivateVoiceZone")

end

end


thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)