A Xamarin multiplatform app that uses the ServiceStack.Client nuget and demonstrates the use of Server-Sent Events.
The backend API that this app connects to is available in this Git repository
The details of the source code is explained in this article
{
public MainPage()
{
InitializeComponent();
EventManager.Instance.Subscribe(
this,
new EventType[]
{
EventType.Comment,
EventType.DirectMessage,
EventType.FriendRequest
});
EventManager.Instance.Unsubscribe(
this,
new EventType[]
{
EventType.DirectMessage
});
}
public void OnEventReceived(ServerEvent serverEvent)
{
Console.WriteLine("Event Type: " + serverEvent.Type);
Console.WriteLine("Event Data: " + serverEvent.Data);
}
}