SteamVoip - stingray.SteamVoip namespace reference - Stingray Lua API Reference

stingray.SteamVoip namespace reference

Description

This is the starting point for voice communication using Steam.

There are three interfaces used for voice communication:

  • SteamVoip: This is the global voice system, in which you can create rooms and clients.
  • SteamVoipRoom: A room is the host for communication between clients. Clients in the same room can talk to each other.
  • SteamVoipClient: A recording and playing entity that sends and receives voice to and from other clients in the same room.

To use voice communication you must first create a room.

You must then update the voice system every frame to allow communication with clients later on.

No voice is recorded at this stage since only clients deal with recording and playback. You need to create two clients on different computers. The creator of the room, the host, can also create a client if that is desired. Only the host can add peers to the room and other peers need to know the room ID to join the room. Therefore it is a good idea to setup two RPCs, one for a join request and one for a join accept.

The peer that wants to create a client sends an RPC to the host.

RPC.want_to_join_room(host)

The host handles the RPC and responds by adding the peer to the room and sending back an RPC that indicates which room the peer should join.

function CallbackObject:want_to_join_room(sender)
        SteamVoipRoom.add_member(self.room_id, sender)
        RPC.accept_join_room(sender, self.room_id)
end

The peer should handle the accept RPC and join the room when accepted.

function CallbackObject:accept_join_room(host, room_id)
        self.client = SteamVoip.join_room(host, room_id)
end

The client peers must now update the VoIP system as well as the host. They provide a callback object to be notified of joining members.

SteamVoip.update(callback_object)

When a new peer is added to the room, all connected clients receive a callback that they must respond to with information on the Timpani event to play and the sound source to play the event on. The Timpani event is a dummy event that needs to exist to set volumes and such things for the voice.

Functions

Parameters
This function does not accept any parameters.
Returns

string

The ID of the created room.

Parameters

room_id :

string

The ID of the room you want to destroy.

Returns
This function does not return any values.
Parameters

host_peer_id :

string

The ID of the room host.

room_id :

string

The ID of the room you want to join.

Returns

stingray.SteamVoipClient

A newly created client that manages this peer's connection to the specified room.

Parameters

client :

stingray.SteamVoipClient

The client that manages the connection.

Returns
This function does not return any values.

The specified client is destroyed.

Parameters

callback_object :

table

A table that contains a set of callback functions that are invoked to respond to changes in the room membership.

Returns
This function does not return any values.

The callback object will receive the following callbacks:

  • room_member_added(room_id, peer_id): timpani_world, event, sound_source? : This is called when a new client has entered the room. You must return the information required to play the voice of the new client. First, you supply the [TimpaniWorld] to play the sound in, as returned by [stingray.World.timpani_world()]. Then you supply the Timpani event to start the voice. This can be an event for a dummy sound that will not be played. Last, a reference must be supplied to indicate where in the world the sound will be heard. You can specify the sound source using any of the following types:
    • nil: The event will be triggered as a 2D sound source.
    • Unit, object_index?: Triggers the timpani event linked to the specified unit (and object if specified).
    • Matrix4x4 : Triggers the timpani event linked to the specified pose.
    • Vector3, Quaternion?: Triggers a Timpani event played at the specified position and optional rotation.
    • sound_source_id: Triggers an event on a sound source returned by a previous [TimpaniWorld.trigger_event()] call.
  • room_member_removed(room_id, peer_id): This is called when a client leaves a room.