Skip to content

Commit

Permalink
docs(unity): add manual message processor
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed Jun 11, 2024
1 parent 4f81560 commit 0e99a35
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions content/unity/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,17 @@ public class ArenaTestButton : MonoBehaviour

// Instantiate the callback for all messages.
scene.OnMessageCallback = MessageCallback;

// Manually ingest a message, not received from MQTT subscriber
scene.ProcessMessage(payload);
}

/// <summary>
/// A delegate method used as a callback to go some special handling on incoming messages.
/// </summary>
public static void MessageCallback(string topic, byte[] message)
public static void MessageCallback(string message)
{
Debug.LogFormat("Message received on topic {0}: {1}", topic, System.Text.Encoding.UTF8.GetString(message));
Debug.LogFormat("Message received: {0}", message);
}

/// <summary>
Expand Down Expand Up @@ -195,7 +198,7 @@ public class ArenaTestButton : MonoBehaviour
client.Publish("my/custom/topic/channel/device-888", System.Text.Encoding.UTF8.GetBytes("some payload"));

// MQTT disconnect
client.DisconnectArena();
client.Disconnect();
}

public class MyArenaClient : ArenaMqttClient
Expand Down

0 comments on commit 0e99a35

Please sign in to comment.