Book Image

SignalR: Real-time Application Development - Second Edition

By : Einar Ingerbrigsten
Book Image

SignalR: Real-time Application Development - Second Edition

By: Einar Ingerbrigsten

Overview of this book

Table of Contents (19 chapters)
SignalR – Real-time Application Development Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
11
Hosting a Server Using Self-hosted OWIN
Index

MVVM


In Chapter 8, Building a WPF .NET Client, we had some help for doing MVVM from a package called Bifrost. This package does not yet support Xamarin, so we are going to borrow some of the concepts from it, although a bit more naïvely implemented. I would recommend taking a look at the source code for Bifrost (http://github.com/dolittle/bifrost), for a fully featured version. For now, however, it will do.

Messenger

The publish/subscribe mechanism we have is fairly simple to implement. Let's add the interface that represents the functionality we need:

  1. Add an interface called IMessenger in the common SignalRChat.Mobile project.

  2. Make the interface look as follows:

    public interface IMessenger
    {
        void Publish<T>(T content);
        void SubscribeTo<T>(Action<T> receivedCallback);
    }
  3. We will need an implementation for the interface; add a class called Messenger sitting in the same project. Make the class look as follows:

    public class Messenger : IMessenger
    {
        Dictionary<Type,...