Developer
API
UDP (Legacy)
Notifications

Notifications API

🚫

Notice: XSOverlay is migrating the Notification API to a websocket protocol. This API remains for legacy support, but further development and support will be migrated to Websocket API


Configuration

XSOverlay, by default, is configured to listen for Notifications messages on port 42069. This can be changed by editing the ExternalMessageAPIConfig.json file located in the [XSOverlayInstallDirectory]/XSOverlay_Data/StreamingAssets/Plugins/Config/ directory.

The following options can be configured:

OptionDescriptionDefault Value
UdpPortThe UDP port XSOverlay listens to messages on.42069

!>XSOverlay ONLY listens for messages from the local host. You CANNOT currently send messages over the network to a different machine


Notification Object

The following is the message object that is to be sent to XSOverlay Notification API.

Notification Markup

PropertyTypeDescriptionDefault Value
messageTypeintThe type of message to send. 1 defines that this is for the Notification API1
indexintUsed for Media Player, changes the icon on the wrist. (depricated, see note below)0
timeoutfloatHow long the notification will stay on screen for in seconds.0.5f
heightfloatHeight notification will expand to if it has content other than a title. Default is 175.175
opacityfloatOpacity of the notification, to make it less intrusive. Setting to 0 will set to 1.1
volumefloatNotification sound volume.0.7f
audioPathstringFile path to .ogg audio file. Can be "default", "error", or "warning". Notification will be silent if left empty.""
titlestringNotification title, supports Rich Text Formatting.""
contentstringNotification content, supports Rich Text Formatting, if left empty, notification will be small.""
useBase64IconboolSet to true if using Base64 for the icon image.false
iconstringBase64 Encoded image, or file path to image. Can also be "default", "error", or "warning".""
sourceAppstringSomewhere to put your app name for debugging purposes.""

!>Media related properties have been depricated


C# Nuget Package

XSOverlay has an officially maintained NuGet Package (opens in a new tab) / Github repository (opens in a new tab) for integrating the Notifications API easily into your C# applications.

Code Samples

C#
//...
using XSNotifications;
using XSNotifications.Enum;
 
namespace NotificationExample1
{
    class Program
    {
        static void Main(string[] args)
        {
            new XSNotifier().SendNotification(new XSNotification(){Title="Notification"});
        }
    }
}

C# Manual Integration

C#
class Program
{
    private struct XSOMessage
    {
        public int messageType { get; set; }
        public int index { get; set; }
        public float volume { get; set; }
        public string audioPath { get; set; }
        public float timeout { get; set; }
        public string title { get; set; }
        public string content { get; set; }
        public string icon { get; set; }
        public float height { get; set; }
        public float opacity { get; set; }
        public bool useBase64Icon { get; set; }
        public string sourceApp { get; set; }
    }
 
    private const int Port = 42069;
 
    private static void Main()
    {
        IPAddress broadcastIP = IPAddress.Parse("127.0.0.1");
        Socket broadcastSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        IPEndPoint endPoint = new IPEndPoint(broadcastIP, Port);
 
        XSOMessage msg = new XSOMessage();
        msg.messageType = 1;
        msg.title = "Example Notification!";
        msg.content = "It's an example!";
        msg.height = 120f;
        msg.sourceApp = "XSOverlay_Example_UDP";
        msg.timeout = 6;
        msg.volume = 0.5f;
        msg.audioPath = "default";
        msg.useBase64Icon = false;
        msg.icon = "default";
        msg.opacity = 1f;
 
        byte[] byteBuffer = JsonSerializer.SerializeToUtf8Bytes(msg);
        broadcastSocket.SendTo(byteBuffer, endPoint);
    }
}