Advertisement
codeplanner

XSockets - Persistence between connections (XStorage)

Apr 30th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3.     <title>XSockets - WeAreTheRealTimeWeb</title>
  4.     <script src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>    
  5.     <script src="/Scripts/JXSockets.1.0.6.beta.js" type="text/javascript"></script>
  6.    
  7.     <script type="text/javascript">
  8.         var ws = null;
  9.         $(function () {
  10.             ws = new jXSockets.xWebSocket("ws://127.0.0.1:4502/Test", jXSockets.WEBSOCKET);
  11.             ws.bind("open", function () {
  12.                 ws.bind("xsockets.storage.get", function (data) {
  13.                     console.log(data);
  14.                 });
  15.             });
  16.             $("#Set").click(function () {
  17.                 ws.trigger("XSockets.Storage.Set", {Key:'foo', Value:$("#Value").val()});
  18.             });
  19.             $("#Get").click(function () {
  20.                 ws.trigger("XSockets.Storage.Get", { Key: 'foo'});
  21.             });
  22.             $("#Remove").click(function () {
  23.                 ws.trigger("XSockets.Storage.Remove", { Key: 'foo' });
  24.             });
  25.         });
  26.     </script>
  27. </head>
  28.     <body>
  29.         <input type="text" id="Value" size="50" placeholder="Store this between websocket connections"/>
  30.         <button id="Set">Set</button>
  31.         <button id="Get">Get</button>
  32.         <button id="Remove">Remove</button>
  33.     </body>
  34. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement