Skip to content
Ashley Muncaster edited this page Apr 13, 2024 · 2 revisions

Events

The Host (Hackbox.Host) component exposes a number of events which can be listened to. You can either listen to the event(s) in code with AddListener, or hook up the event listener(s) in the Unity inspector.

Name Parameters Description
OnRoomCreated string: Room Code Called when a room is created. This does not mean that the Host is currently connected to the room yet.
OnRoomConnected string: Room Code Called when the host connects to the room. The string parameter is the room code of the room.
OnRoomDisconnected string: Room Code Called when the host disconnects from the room, either from Unity side or server side.
OnRoomReconnecting string: Room Code Called when the host tries reconnecting to the room.
OnRoomReconnectFailed string: Room Code Called when the host fails to reconnect to the room.
OnMemberJoined Hackbox.Member: Joining member Called when a member joins the room.
OnMemberKicked Hackbox.Member: Kicked member Called when a member is kicked from the room.
OnMessage Hackbox.Message: Message Called when a member sends input from their Hackbox client.
OnPingPong Called when a ping-pong event occurs on the host connection.

Messages

Members can send Messages (Hackbox.Message) from their Hackbox client, such as text from a TextInput component, or a button selection from a Choices component. A Message consists of the following information:

  • Member (Hackbox.Member): The Member that sent the message
  • ID (string): A unique identifier for this specific message; should be unique for every message
  • Timestamp (System.DateTimeOffset): The timestamp of when the message was sent from the client
  • Event (string): The name of the event in the message
  • Value (string): The value (singular) in the message; TextInput, single-choice Choices, and Range components will send events with a Value
  • Values (string[]): The values (plural) in the message; multi-choice Choices will send events with Values
Clone this wiki locally