Skip to content Skip to sidebar Skip to footer

Signal R Notification

I am creating an application using signal r to send notification. I am using VS 2012. In my Notification view I have added the code below in @model App.Models.Notification. @{

Solution 1:

You also need to create a owin startup class. I will put code here for that (view same as your) :-

<script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/jquery.signalR-2.1.2.min.js"></script>
    <script src="/signalr/hubs"></script>

    <script type="text/javascript">
        $(function () {

            var proxy = $.connection.notificationHub;
            alert(proxy);
            $("#button1").click(function () {
                alert($("#text1").val());
                proxy.server.sendNotifications($("#text1").val());
                alert(12);
            });
            $.connection.hub.start();

            alert(14);
        });
    </script>

Notification Hub like :

public class NotificationHub : Hub
{
    public void Hello()
    {
        Clients.All.hello();
    }

    public void SendNotifications(string message)
    {
        Clients.All.receiveNotification(message);
    }
}

Now Most importnant you need to create a owin startup class to start signal r, code like :

    public void Configuration(IAppBuilder app)
    {
        app.MapSignalR();
    }

Post a Comment for "Signal R Notification"