Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
razzul authored Jul 2, 2018
1 parent 0a6f2c9 commit 8714f95
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions stay-alive.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,12 @@ public function stay_alive_auth()

public function user_in($current_user)
{
$options = get_option('stay_alive_credentials');
$current_user = $user_obj = get_user_by('login', $current_user );

$channel_name = 'presence-stay-alive-channel';
$event_name = 'stay-alive-event';

require __DIR__ . '/vendor/autoload.php';
$pusher = new Pusher\Pusher($options['pusher_key'], $options['pusher_secret'], $options['pusher_app_id'], array('cluster' => $options['pusher_cluster']));

$pusher->trigger($channel_name, $event_name, array('online' => true, 'user' => $current_user));
//echo '<script>stay_alive.online(test_stay_alive)</script>';

}

public function user_logout()
{
$options = get_option('stay_alive_credentials');
$current_user = wp_get_current_user();

$channel_name = 'presence-stay-alive-channel';
$event_name = 'stay-alive-event';

require __DIR__ . '/vendor/autoload.php';
$pusher = new Pusher\Pusher($options['pusher_key'], $options['pusher_secret'], $options['pusher_app_id'], array('cluster' => $options['pusher_cluster']));
$pusher->trigger($channel_name, $event_name, array('online' => false));
echo '<script>stay_alive.unsubscribe("' . $channel_name . '")</script>';

}

public function stay_alive_checker()
Expand All @@ -107,9 +88,7 @@ public function stay_alive_checker()
<script>
function test_stay_alive(members) {
members.each(function(member) {
console.log(member);
});
console.log(members);
}
console.log("StayAlive: loaded");
Expand Down Expand Up @@ -151,9 +130,9 @@ function test_stay_alive(members) {
stay_alive.subscribe()
this.channel.bind("pusher:subscription_succeeded", function(members) {
if(callback == "") {
test_stay_alive(members)
test_stay_alive(members.members)
} else {
callback(members)
callback(members.members)
}
});
Expand Down Expand Up @@ -384,7 +363,7 @@ public function pusher_cluster_callback()
public function stay_alive_trigger_callback()
{
printf(
'<input type="text" id="stay_alive_trigger" name="stay_alive_credentials[stay_alive_trigger]" value="%s" />',
'<input type="text" id="stay_alive_trigger" name="stay_alive_credentials[stay_alive_trigger]" value="%s" /><br><span>Default value: test_stay_alive</span><br><b>No need to user parenthesis symbol "()"</b>',
isset($this->options['stay_alive_trigger']) ? esc_attr($this->options['stay_alive_trigger']) : ''
);
}
Expand Down

0 comments on commit 8714f95

Please sign in to comment.