User:Ftwm/JTSetc

From Rabid Reaction Force
Revision as of 13:43, 22 June 2024 by Ftwm (talk | contribs) (Created page with "==Pusher.com Channels client== ====HTM==== <code> <!DOCTYPE html><html><head> <title>Pusher Test</title> <script src="https://js.pusher.com/8.2.0/pusher.min.js"></script> <script src="./privtest.js"></script> <style> code { color: blue; } </style> </head><body> <h1>Pusher.com 'Channels' product test</h1> <p> <label for="ak_">Access Key</label> <input type="text" id="ak" name="ak_" onchange="tryNewAppKey(this.value)" > </p> <p>...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Pusher.com Channels client

HTM

<!DOCTYPE html><html><head>

 <title>Pusher Test</title>
 <script src="https://js.pusher.com/8.2.0/pusher.min.js"></script>
 <script src="./privtest.js"></script>
 <style> code { color: blue; } </style>

</head><body>

Pusher.com 'Channels' product test

<label for="ak_">Access Key</label> <input type="text" id="ak" name="ak_" onchange="tryNewAppKey(this.value)" >

Test by triggering an event on channel 'main-channel' with event name 'dumb-event' - for example by:-
(i) creating an account
(ii) downloading the pusher CLI
(iii) logging in with your API key:
"pusher login"
(iv) triggering a dumb-event on the main-channel:
"pusher channels apps trigger --app-id 1736956 --channel main-channel --event dumb-event --message hello-world"

waiting...

</body></html>

JS

var always = true; // const never= false;

var _ = { _: undefined }; _._ = _;

/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ var pusher = null; // var channel= null; // var pusher_= null; var eventHandler = function (stuff) {

   stuff;
   var counter = 0;
   var ret = function (data) {
       var s = JSON.stringify(data);
       document.body.innerText +=
           "; msg#" + ++counter + ":" + s;
   };
   return ret;

}; function tryNewAppKey(val) {

   if (val.length == 20) { }
   else
       return;
   pusher = new Pusher(val, {
       cluster: 'eu', channelAuthorization: {
           //          transport: "jsonp",
           endpoint: "http://localhost:8080/pusher/auth"
       }
   });
   Pusher.logToConsole = true; // Enable pusher logging - don't include this in production
   var channel = pusher.subscribe('nonprivate-channel');
   channel.bind("pusher:subscription_error", function () { console.log("NOPE!"); });
   channel.bind("pusher:subscription_succeeded", function () { channel.bind('unremarkable-event', eventHandler()); });

} /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/