-
-
Save UnderDogg/569e742675071862627d1a266cd305a6 to your computer and use it in GitHub Desktop.
laravel long pulling only allows 1 pull to be going at any time by utilizing the file system.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Checkin = (function(window, document, undefined) { | |
var s = { | |
contact: {} | |
}, | |
showing = false; | |
function init() { | |
bindVerify(); | |
bindDeny(); | |
waitForMsg(); | |
} | |
function bindDeny() { | |
c.on('click', '[data-deny-contact]', function(){ | |
$.get('/focus/contact/deny', s.contact, function(){ | |
$('.verify-contact').slideUp('medium'); | |
toastr.success("Contact denied check-in."); | |
}); | |
}); | |
} | |
function bindVerify() { | |
c.on('click', '[data-verify-contact]', function(){ | |
$.get('/focus/contact/verify', s.contact, function(){ | |
$('.verify-contact').slideUp('medium'); | |
toastr.success("Contact verified for check-in."); | |
}); | |
}); | |
} | |
function waitForMsg() { | |
$.get('/focus/contact/verify', function(data){ | |
var view = viewVerify(data); | |
s.contact = data; | |
$('.verify-contact').show(0).html(view); | |
setTimeout(function(){ | |
waitForMsg() | |
}, 20000); | |
}); | |
} | |
function viewVerify(data) { | |
var page = "<div class='alert alert-block text-center'> \ | |
<h4>Please Verify Patient At Check-in</h4> \ | |
<br> \ | |
" + data.first + " " + data.last + " | " + data.email + " | " + data.phone + " \ | |
<br> \ | |
<br> \ | |
<span class='btn btn-success' data-verify-contact>Verify</span> \ | |
<span class='btn btn-danger' data-deny-contact>Deny</span> \ | |
</div> \ | |
"; | |
return page; | |
} | |
init(); | |
})(this, document); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function get_checkin_poll() | |
{ | |
$filepath = 'storage/work/checkin_poll_' . Auth::user()->id; | |
$last_cycle = File::get($filepath); | |
// if last cycle was > 40 secs continue | |
$time_dif = time() - $last_cycle; | |
Log::time($time_dif); | |
if ($time_dif < 40) { | |
Log::stop(''); | |
exit; | |
} | |
$thread = uniqid(); | |
while (1) { | |
Log::cycle($thread); | |
$user = User::find(Auth::user()->id); | |
// if last actiiity was > 40 seconds stop | |
$active_dif = time() - $user->activity_at; | |
if ($active_dif < 40) | |
exit; | |
$contact = Contact::where_account_user_id(Auth::user()->account_user_id) | |
->where_request(1) | |
->first(); | |
if ($contact != null) | |
break; | |
// save time of last cycle | |
File::put($filepath, time()); | |
sleep(2); | |
} | |
File::put($filepath, ''); | |
return Response::eloquent($contact); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment