(Created page with "The SNetwork class allows you to send messages to other users in the region, and persist/retrieve variables which have been stored within the region. ==Members== {{ScriptFunc...") |
(→Members) |
||
Line 2: | Line 2: | ||
==Members== | ==Members== | ||
− | {{ScriptFunction|void|SendNetworkMessage|(string key, IDictionary<object,object>);|Sends a networked message to every client with a subscriber listening on 'key'. The message itself can be a dictionary/table containing two columns and any network serializable type (string, float, int, byte, bool and arrays of those types)}} | + | {{ScriptFunction|void|SendNetworkMessage|(string key, IDictionary<object,object>);|Sends a networked message to every client with a subscriber listening on 'key'. The message itself can be a dictionary/table containing two columns and any network serializable type (string, float, int, byte, bool and arrays of those types)<br><br> |
+ | This is a modified version of the example for *.Renderer.Material.SetTexture that demonstrates networking.<br><br>note that this example applies also to SubscribeToNetwork.|5 = image = "mrlee.jpg" | ||
+ | server = "https://middleware.systems/" | ||
+ | obj = Space.Host.GetReference("Gino") | ||
+ | |||
+ | Space.Network.SubscribeToNetwork("smack", onSmack) | ||
+ | |||
+ | function hithere() | ||
+ | resrc = Space.WebServices.GetImage(server .. "mrlee.jpg") | ||
+ | obj.Renderer.Material.SetTexture("_MainTex", resrc) | ||
+ | Space.Network.SendNetworkMessage("smack",{'smack'}) | ||
+ | end | ||
+ | |||
+ | function update() | ||
+ | resrc = Space.WebServices.GetImage(server .. "mrlee.jpg") | ||
+ | obj.Renderer.Material.SetTexture("_MainTex", resrc) | ||
+ | end | ||
+ | |||
+ | function onSmack() | ||
+ | update() | ||
+ | end}} | ||
{{ScriptFunction|void|SetShardProperty|(string key, string value);|Sets a property named 'key' of the region to 'value'. Will persist until the region is shut down or restarted. (Use SPersistence for longer term storage)}} | {{ScriptFunction|void|SetShardProperty|(string key, string value);|Sets a property named 'key' of the region to 'value'. Will persist until the region is shut down or restarted. (Use SPersistence for longer term storage)}} | ||
{{ScriptFunction|string|GetShardProperty|(string key);|Gets a previously set key.}} | {{ScriptFunction|string|GetShardProperty|(string key);|Gets a previously set key.}} |
The SNetwork class allows you to send messages to other users in the region, and persist/retrieve variables which have been stored within the region.
Sends a networked message to every client with a subscriber listening on 'key'. The message itself can be a dictionary/table containing two columns and any network serializable type (string, float, int, byte, bool and arrays of those types)
This is a modified version of the example for *.Renderer.Material.SetTexture that demonstrates networking.
note that this example applies also to SubscribeToNetwork.
server = "https://middleware.systems/" obj = Space.Host.GetReference("Gino")
Space.Network.SubscribeToNetwork("smack", onSmack)
function hithere()
resrc = Space.WebServices.GetImage(server .. "mrlee.jpg") obj.Renderer.Material.SetTexture("_MainTex", resrc) Space.Network.SendNetworkMessage("smack",{'smack'})
end
function update()
resrc = Space.WebServices.GetImage(server .. "mrlee.jpg") obj.Renderer.Material.SetTexture("_MainTex", resrc)
end
function onSmack()
update()end
Sets a property named 'key' of the region to 'value'. Will persist until the region is shut down or restarted. (Use SPersistence for longer term storage)
Gets a previously set key.
Subscribes to network messages on 'key', will fire a Scripting/SNetworkMessage whenever a matching message is received
|