javascript - Callback on client does not get triggered with SignalR -


i'm getting speed signalr, , tried build basic message notification system using basic understanding of signalr have can't messages come after submission.

i've read on numerous blogs on topic , basic have void method accepts string value , passes attaching clients context, however, not work for, onreceivenotification() undefined in js debugger?

am missing something

notificationhub.cs

[hubname("notificationhub")] public class notificationhub : hub {      public override system.threading.tasks.task onconnected()     {         return base.onconnected();     }      public override system.threading.tasks.task ondisconnected(bool stopcalled)     {         return base.ondisconnected(stopcalled);     }      public override system.threading.tasks.task onreconnected()     {         return base.onreconnected();     }      [hubmethodname("sendnotifications")]     public void sendnotifications(string message)     {         clients.all.onrecievenotification(string.format("{0} {1}", message, datetime.now.tostring()));     } } 

message.html page

<div>     <input type="text" id="messageinput" />     <button id="notifybutton">send message</button> </div>  <script src="scripts/jquery-2.1.4.min.js"></script> <script src="scripts/jquery.signalr-2.2.0.min.js"></script> <script src="signalr/hubs"></script> <script type="text/javascript">     jquery(document).ready(function ($)     {         var $hub = $.connection.notificationhub;         $.connection.hub.start();          $(document).on("click", "#notifybutton", {}, function (e)         {             e.preventdefault();             var $message = $("#messageinput").val();             $hub.server.sendnotifications($message);         });     }); </script> 

display.html

<div>     <ul id="messages"></ul> </div>  <script src="scripts/jquery-2.1.4.min.js"></script> <script src="scripts/jquery.signalr-2.2.0.min.js"></script> <script src="signalr/hubs"></script> <script type="text/javascript">     jquery(document).ready(function ($)     {         var $hub = $.connection.notificationhub;          $hub.onrecievenotification = function (message)         {             $("#message").append($("<li></li>", { text: message }));         }          $.connection.hub.start();     }); </script> 

it looks missing client in:

   $hub.client.onrecievenotification = function (message)     {         $("#message").append($("<li></li>", { text: message }));     } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -