Book Image

SignalR Blueprints

By : Einar Ingerbrigsten
Book Image

SignalR Blueprints

By: Einar Ingerbrigsten

Overview of this book

Table of Contents (18 chapters)
SignalR Blueprints
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
9
Debugging or Troubleshooting
Index

Our first hub – threads


Now that we have our data access layer and the models in place, we want to expose our first SignalR hub, enabling us to actually work with this from the client. At the root of the project, add a folder called Hubs, and inside this folder, create another folder called Forum. In this folder, we want to add a C# class called ThreadHub.cs. Start by adding the following code in it:

using System;
using System.Collections.Generic;
using System.Linq;
using Chapter2.DAL;
using Chapter2.Models.Forum;
using Microsoft.AspNet.SignalR;

namespace Chapter2.Hubs.Forum
{
    public class ThreadHub : Hub
    {
        ForumContext _forumContext;
        
        public ThreadHub()
        {
            _forumContext = new ForumContext();
        }
        
        protected override void Dispose(bool disposing)
        {
            if (disposing) 
            {
               _forumContext.Dispose();
            }
            base.Dispose(disposing)
        }
    }
}

Note

Being a good...