Send Messages

Inherit from EasyManager.cs

using EasyCodeForVivox;

public class VivoxManager : EasyManager
{

}

Inject EasyMessages

using EasyCodeForVivox;
using UnityEngine;
using Zenject;

public class VivoxMessages : MonoBehaviour
{
    EasyMessages _messages;

    [Inject]
    private void Initialize(EasyMessages messages)
    {
        _messages = messages;
    }
}

Send Messages

  • Send a channel message to everyone in the channel. Channels can hold up to 200 players/users. After that you will get an error if you try to join a channel that has 200 players

  • To send a direct message to a player, players must know each other's names. I would recommend using a 3rd party service or implement your own to see which players are logged in.

Send Channel Message

To send messages in a Text channel the player must be connected to an active channel with Text capabilities. You can also provide secret messages (Also known as event messages in EasyCode) that only the developer can see unless you wish your players to see these messages. In the Vivox Documentation this is referred to as applicationStanzaNamespace and applicationStanzaBody.

For more info on applicationStanzaNamespace and applicationStanzaBody check out this blog post

I have chosen to use Web API lingo and will refer to them as stated below

  • applicationStanzaNamespace = header

  • applicationStanzaBody = body

I have 2 examples of how to send a channel message

  • I am sending a message on behalf of user "userName" inside of a channel called "chat"

  • In the 2nd example I am sending a secret message (event message). These are not meant for all players to see but rather the developers.

EasyManager

public void SendChannelMessage()
{
    SendChannelMessage("userName", "chat", "my message to everyone");
    SendChannelMessage("userName", "chat", "my message to everyone", header: "squad", body: "1");
}

EasyMessages

public void SendChannelMessage()
{
    _messages.SendChannelMessage(EasySession.ChannelSessions["chat"], "my message to everyone");
    _messages.SendChannelMessage(EasySession.ChannelSessions["chat"], "my message to everyone", header: "squad", body: "1");
}

Send Direct Message

Send direct messages to a logged in user. Both players must be connected to Vivox server's or the message will fail. To send a direct message to a player, players must know each other's names. I would recommend using a 3rd party service or implement your own to see which players are logged in. You can also provide secret messages that only the developer can see unless you wish your players to see these messages. In the Vivox Documentation this is referred to as applicationStanzaNamespace and applicationStanzaBody.

For more info on applicationStanzaNamespace and applicationStanzaBody check out this blog post

I have chosen to use Web API lingo and will refer to them as stated below

  • applicationStanzaNamespace = header

  • applicationStanzaBody = body

I have 2 examples of how to send a direct message

  • I am sending a direct message (DM) on behalf of user "userName" to my friend "myFriendsName"

  • In the 2nd example I am sending a secret message (event message). These are not meant for all players to see but rather the developers.

EasyManager

public void SendDirectMessage()
{
    SendDirectMessage("userName", "myFriendsName", "my message to everyone");
    SendDirectMessage("userName", "myFriendsName", "my message to everyone", header: "squad", body: "1");
}

EasyMessages

public void SendDirectMessage()
{
    _messages.SendDirectMessage(EasySession.LoginSessions["userName"], "myFriendsName", "my message to everyone");
    _messages.SendDirectMessage(EasySession.LoginSessions["userName"], "myFriendsName", "my message to everyone", header: "squad", body: "1");
}

Send Event Message

This feature is experimental but has been included. may be removed/deprecated later

Event messages are secret messages that only the developer can see unless you wish your players to see these messages. In the Vivox Documentation this is referred to as applicationStanzaNamespace and applicationStanzaBody.

For more info on applicationStanzaNamespace and applicationStanzaBody check out this blog post

Last updated