Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everone,
Currently i am working with SignalR in Angular JS.
What i am trying to do is, users can send IM to other users & user will find that notification in Home page.
Problem is that it get notified user Home Page but after refreshing home page all data get lost.
Can anyone help me on this? I want to persist data on page re load.

My Code is in js file like bellow

JavaScript
function SendMessage(message, From, sendTo) {

           $scope.hubIM.on("receiveIM", function (message) {
             // $scope.IM.push(message);

              $scope.IM.push({ "messageText": message });
              console.log(message);

              $('#MyMessage').append('<li>' +message + '</li>');"JavaScript">//#MyMessage in Home Page

           });
           $scope.connection.start().done(function () {
              // console.log(&#39;Connection open&#39;)
              // console.log($scope.connection)
               //alert(&#39;vv&#39;);
               $scope.hubIM.invoke(&#39;sendIM&#39;, sendTo, message);

           })
           $scope.connection.disconnected(function () {
               setTimeout(function () {
                   $scope.connection.hub.start();
               }, 5000); // Restart connection after 5 seconds.
           });</pre>
Posted
Comments
Sri Nivas (Vasu) 20-Jan-16 5:44am    
Do you want to store messages permanently or you want to display data temporary only for the each session?
If you want to store data permanently then your data display should come from database it will display complete data even after page refresh.

If you want to store data temporary try client side storage of chat with date time(so that you can kill data if you want.) and on page load display the stored chat if available.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900