Suduxu
API

Clients API

Manage connected devices and communicate with individual clients or broadcast targets.

Clients represent connected devices inside the Suduxu runtime. Each client exposes control, input state, and messaging capabilities through a unified API.


Retrieving client meta data

let clients: Vec<SuduxuDevice> = find_all_clients();
let client1: Option<SuduxuDevice> = find_client_by_id(1);
List<SuduxuDevice> clients = suduxu.FindAllClients();
SuduxuDevice client1 = suduxu.FindClientById(1);

Client access

Clients are accessed through explicit handles.

for_client(id)
for_broadcast()

The default client id to be used is configured when initializing Suduxu, with 0 reserved for broadcast.

suduxu.Input.For(id);
suduxu.Client.Broadcast();

The default client id to be used is configured in the Unity Editor on the Suduxu Component element, with 0 reserved for broadcast.


Sending commands

Clients support bidirectional communication via payload-based commands.

Vibration

for_client(id).vibrate(750, VibrationStrength::Medium, VibrationType::Custom);

Sound

for_client(id).play_sound("click");

For a sound to be played, it must be included in the suduxu.json configuration file and to play it, it's name must be provided

Sensor control

for_client(id).send_sensor_data(true);

This command enables or disables the flow of sensor data from the client device.

Sensor transmission rate

for_client(id).set_sensor_transmission_rate(60);

The sensor transmission rate can be set to any value between 10 and 200 FPS.

Setting the sensor transmission rate to a very high value may impact performance. Furthermore clients can decide in the settings, what their maximum sensor transmission rate is, so the command may not always succeed in setting the desired sensor transmission rate, although it will be clamped to the maximum supported by the client.

Logging

for_client(id).log(LogLevel::Info, "Message", Some("Title"));

File

for_client(id).file("theme");

This command requests a clients to load a file from the file server.

Vibration

suduxu.Client.For(id).Vibrate(750, VibrationStrength.Medium, VibrationType.Custom);

Sound

suduxu.Client.For(id).PlaySound("click");

For a sound to be played, it must be included in the suduxu.json configuration file and to play it, it's name must be provided

Sensor control

suduxu.Client.For(id).SendSensorData(true);

This command enables or disables the flow of sensor data from the client device.

Sensor transmission rate

suduxu.Client.For(id).SetSensorTransmissionRate(60);

The sensor transmission rate can be set to any value between 10 and 200 FPS.

Setting the sensor transmission rate to a very high value may impact performance. Furthermore clients can decide in the settings, what their maximum sensor transmission rate is, so the command may not always succeed in setting the desired sensor transmission rate, although it will be clamped to the maximum supported by the client.

Logging

suduxu.Client.For(id).Log(LogLevel.Info, "Message", "Title");

File

suduxu.Client.For(id).File("theme");

This command requests a clients to load a file from the file server.


Input state queries

Clients can query real-time input state from devices.

for_client(id).get_button_released(ButtonInputType::A); // Returns true if the button was released (Cancel/Up) in the current frame
for_client(id).get_button_down(ButtonInputType::A); // Returns true if the button is currently being pressed (Down) in the current frame
for_client(id).get_button(ButtonInputType::A); // Returns true if the button was pressed (Pressed/Down) in the current frame
for_client(id).get_button_up(ButtonInputType::A); // Returns true if the button was released (Up) in the current frame
for_client(id).get_button_in_state(ButtonInputType::A, ButtonInputState::Pressed); // Returns true if the button is in the specified state in the current frame
suduxu.Input.For(id).GetButtonReleased(ButtonInputType.A); // Returns true if the button was released (Cancel/Up) in the current frame
suduxu.Input.For(id).GetButtonDown(ButtonInputType.A); // Returns true if the button is currently being pressed (Down) in the current frame
suduxu.Input.For(id).GetButton(ButtonInputType::A); // Returns true if the button was pressed (Pressed/Down) in the current frame
suduxu.Input.For(id).GetButtonUp(ButtonInputType.A); // Returns true if the button was released (Up) in the current frame
suduxu.Input.For(id).GetButtonInState(ButtonInputType.A, ButtonInputState.Pressed); // Returns true if the button is in the specified state in the current frame

Direct client operations

disconnect_client(id);
disconnect_all();
suduxu.DisconnectClient(id);
suduxu.DisconnectAll();

Notes

  • All operations are asynchronous at runtime level
  • Commands are serialized into payloads before transmission
  • Input state is polled from native runtime and may lag slightly behind real-time events

In order to use the suduxu object in Unity it first needs to be injected, this is achieved the following way:

public class SuduxuExample : MonoBehaviour {
  [injected]
  private Suduxu suduxu;
}

Otherwise it can also be called like this:

Suduxu.Instance

On this page