-
-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrent XHR for rpc and prompt #474
Comments
The sequential way is to load |
Hi, using Thank you. |
Do you a demo somewhere where I can test your code? |
I do have a link.. but it requires a password etc |
Hi, In case I wasn't clear enough, I'm looking to make fetching While it is possible to switch to locked sessions, that comes with a performance hit. Thank you. |
I'm not sure how async: false will work. Here is working example with rpc demo where I set session in php for each rpc command: jQuery(document).ready(function($) {
$('body').terminal("json-rpc-service-demo.php", {
login: true,
greetings: "You are authenticated",
completion: true,
onBlur: function() {
// the height of the body is only 2 lines initialy
return false;
},
prompt: function(setPrompt) {
$.jrpc('json-rpc-service-demo.php', 'prompt', [],
function(response) {
setPrompt(response.result);
});
}
});
}); and it work, prompt rpc is executed after rpc finish. |
if you're using normal ajax without build in RPC then you need to pause the terminal when you do ajax call, and resume after it finish and you echo the result. If you have problem with timing you probably need pasue/resume or return promise from interpreter (but that promise need to resolve to undefined otherwise the value from promise will get echoed, but if you return and have |
Hi, I assume you are using PHP's It is blocking by default aka locked, i.e. when RPC has called I tested using
I'm going to try the pause and resume now and update my results. Thank you. |
Hi, I managed to get what I wanted. Here is to tie a few loose ends: Make
|
if (is_function(prompt)) { | |
draw_prompt(); | |
} |
prompt
currently fires twice, first, together with RPC
, and again after RPC
ends (refer to chrome network logs)ENTER
without any command, we will fire the first prompt
(as RPC
will not fire)ENTER
with a command, we do not fire the first prompt
and let RPC
fire prompt
after endingprompt
is fired only 1 time.AJAX with async: false
- This causes the AJAX not to return until it's
done()
is finished - It has little effect on terminal, probably just a slightly longer delay
Thank you for the time and help!
If you use code to trigger ajax even $.jrpc you need to use pause()/resume(), by default rpc I mean using string as interpreter, that will create RPC client for you. (like in my code). This is not blocking in PHP the request is not fired until first is finished because prompt is called when you call resume(). If it would lock the other session there would be two request but send would take longer but it start when first is finished. |
I can confirm that in your code but you didn't send the link and pass. |
Hi, I did not send the link as I had solved it. Let me test your |
Would you have an example of where to call
It causes an infinite loop. |
You need to put those in your interpreter, can you show your first argument to |
Here's the terminal portion:
|
that's very weird it work with php when I tested, I've just removed session_start and replace it with file on disk and it works. Without having it live nothing I can do, the only thing I can think of is that you use outdated version. Ps: this will not work: onIdle: function (term) {
term.resize();
$('#s').trigger('click');
},
completion: function (term, string, callback) {
return true;
},
onBlur: function () {
return false;
},
without calling callback make no sens, if you use rpc use and |
wait, sorry it seems that there are two requests, but they are both the same, this is a bug. There should be only one request to prompt. |
Thanks for highlighting the deprecated functions. Yes, I have used Since you now see two |
The fix is in devel branch it will be in version 2.2.1. |
Thank you, I can confirm there is only 1 prompt call now. |
There are still issues with async prompt it's executed 2 times on init and the solution work with old jQuery. |
Should be fixed now, also found few other async prompt issues. Those are also fixed. |
I have question related to jQuery Terminal
Hi,
I configured
prompt
to load a URL (using AJAX/XHR) which returns some Laravel session data. However, my URL randomly returns outdated data.I did some tracing using Chrome's network logs, and see that
prompt
's URL is loaded concurrently with the RPC's URL.Is there any way to make it sequential? i.e. prompt URL is loaded only after RPC's URL is completed. Thank you.
The text was updated successfully, but these errors were encountered: