# SShared

**Membres** 7

|          |                                                             |                                                                                                                 |
| -------- | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Fonction | [SetGlobal](#setglobal)                                     | Sets a global key to a value.                                                                                   |
| Fonction | [GetGlobal](#getglobal)                                     | Retrieves a previously set global variable, or returns nil.                                                     |
| Fonction | [RegisterFunction](#registerfunction)                       | Makes func into a global function that can be accessed anywhere.                                                |
| Fonction | [RegisterBroadcastFunction](#registerbroadcastfunction)     | Makes func into a global function that can be accessed anywhere.                                                |
| Fonction | [UnregisterBroadcastFunction](#unregisterbroadcastfunction) | Unregister Broadcast Function.                                                                                  |
| Fonction | [CallFunction](#callfunction)                               | Calls the registered function with the specified arguments.                                                     |
| Fonction | [CallBroadcastFunction](#callbroadcastfunction)             | Calls every registered broadcast function with the specified arguments, and returns the number of calls queued. |

## Fonctions

### SetGlobal

void SetGlobal(string ns, string key, DynValue value)

Sets a global key to a value. The value can be any object type.

Paramètres

| Nom   | Type     | Valeur par défaut |
| ----- | -------- | ----------------- |
| ns    | string   | –                 |
| key   | string   | –                 |
| value | DynValue | –                 |

Valeurs de retour

`void`

Exemple

**Lua**

```lua
Space.Shared.SetGlobal("com.someNameHere.world", "version", "1.02");

```

### GetGlobal

DynValue GetGlobal(string ns, string key)

Retrieves a previously set global variable, or returns nil.

Paramètres

| Nom | Type   | Valeur par défaut |
| --- | ------ | ----------------- |
| ns  | string | –                 |
| key | string | –                 |

Valeurs de retour

`DynValue`

Exemple

**Lua**

```lua
local versionValue = Space.Shared.GetGlobal("com.someNameHere.world", "version")

```

### RegisterFunction

void RegisterFunction(string ns, string func, Closure reference)

Makes func into a global function that can be accessed anywhere.

Paramètres

| Nom       | Type    | Valeur par défaut |
| --------- | ------- | ----------------- |
| ns        | string  | –                 |
| func      | string  | –                 |
| reference | Closure | –                 |

Valeurs de retour

`void`

Exemple

**Lua**

```lua
function someFunction(name)
  Space.Log("Hello " .. name);
end

Space.Shared.RegisterFunction("com.someNameHere.world", "func", someFunction);

```

### RegisterBroadcastFunction

void RegisterBroadcastFunction(string ns, string func, Closure reference)

Makes func into a global function that can be accessed anywhere.

Paramètres

| Nom       | Type    | Valeur par défaut |
| --------- | ------- | ----------------- |
| ns        | string  | –                 |
| func      | string  | –                 |
| reference | Closure | –                 |

Valeurs de retour

`void`

Exemple

**Lua**

```lua
function someFunction(name)
  Space.Log("Hello " .. name);
end

Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);

```

### UnregisterBroadcastFunction

void UnregisterBroadcastFunction(string ns, string func, Closure reference)

void UnregisterBroadcastFunction(string ns, string func)

Unregister Broadcast Function.

Paramètres

| Nom       | Type    | Valeur par défaut |
| --------- | ------- | ----------------- |
| ns        | string  | –                 |
| func      | string  | –                 |
| reference | Closure | –                 |

Valeurs de retour

`void`

Exemple

**Lua**

```lua
example 1

```

### CallFunction

void CallFunction(string ns, string func, IEnumerable< DynValue > args)

Calls the registered function with the specified arguments.

Paramètres

| Nom  | Type                    | Valeur par défaut |
| ---- | ----------------------- | ----------------- |
| ns   | string                  | –                 |
| func | string                  | –                 |
| args | IEnumerable< DynValue > | –                 |

Valeurs de retour

`void`

Exemple

**Lua**

```lua
Space.Shared.CallFunction("com.someNameHere.world", "func",{"Smith"});

```

### CallBroadcastFunction

int CallBroadcastFunction(string ns, string func, IEnumerable< DynValue > args)

Calls every registered broadcast function with the specified arguments, and returns the number of calls queued.

Paramètres

| Nom  | Type                    | Valeur par défaut |
| ---- | ----------------------- | ----------------- |
| ns   | string                  | –                 |
| func | string                  | –                 |
| args | IEnumerable< DynValue > | –                 |

Valeurs de retour

`int`

Exemple

**Lua**

```lua
example 1

```
