World: r3wp
[!Cheyenne] Discussions about the Cheyenne Web Server
older newer | first last |
Terry 30-Dec-2009 [6990x5] | My rebol is rusty.. Keep adding semi-colons to lines of code |
Just fooling around.. there's some interesting behviour here... changed the on-timer function in ws-test-app.r file to... on-timer: does [ foreach port clients [ out: do %test.r send/with out port ] ] .. and created a test.r file in Cheyenne's root thus.. rebol [] a: "42" b: "43" out1: rejoin ["OUT1: " b] out2: rejoin ["out2: " a] out1 | |
seems whatever the last thing that is "done" in the test.r script becomes the response message. | |
append this to the end of test.r {hollow words} and that's the response | |
What is cool, is that there's no need to reload the Cheyenne config files. | |
Dockimbel 30-Dec-2009 [6995] | Graham: yes possible, but maybe overkill, a simple one-page script might do the job fine, no? |
Graham 30-Dec-2009 [6996x4] | Well, currently I download the update and then write a command script that deletes the current application, and then renames the download to the application name, and then starts it up, call the command script and quit. But forwhatever reasons .. it often fails |
due to a file lock on the application ... maintained by whatever ... | |
so instead of using a command script .. I thought I could use Cheyenne instead as that is always running. | |
If the script then fails, it could check to see if the application is still running and kill it somehow. | |
sqlab 31-Dec-2009 [7000x2] | Is this correct, that I do not see any output in the console of a cheyenne instance started with -vvvvv, when I click on the "Send Message" button of ws.html? |
Sorry, I just realized, that FF does not support them. | |
Dockimbel 31-Dec-2009 [7002x2] | Chrome 4 only currently. |
Graham: I have a client application using a similar method to do updates. Once the update exe is downloaded : write/binary %application-maj.exe decompress res wait 0.5 call "application-maj.exe" quit Then, the first thing the application does when started is : if find system/options/boot "application-maj" [ delete %application.exe call/wait "copy application-maj.exe application.exe" wait 0.5 call "application.exe" quit ] if exists? %application-maj.exe [ attempt [delete %application-maj.exe] ] | |
Graham 31-Dec-2009 [7004x2] | I think the issue occurs when the user runs two copies of the application .. so it can never be deleted. |
I see your way dispenses with the need to run a command script. | |
Dockimbel 31-Dec-2009 [7006] | It's working ok, but in fact, the only 100% reliable way and most efficient way of making updates is by downloading new REBOL source code in encrypted format. Your exe becomes then basically a "loader" with a built-in default version of the application. On each start, it should scan online for new versions and scan local disk for cached updates. |
Graham 31-Dec-2009 [7007x3] | Yeah .. I think that's what Gabriele has suggested in the past. |
The other way I used to do it was maintain binary diffs and xor them back to update the main binary .. but again that requires the user not to run two copies :( | |
BTW, since rebol code is already compressed .. .do you gain much by compressing it further as in above? | |
Dockimbel 31-Dec-2009 [7010] | REBOL code payload is compressed but not the REBOL kernel compiled C part. The gain is around 40% in my case. |
Terry 31-Dec-2009 [7011x3] | How stable is Cheyenne's PHP handling these days? |
Doc, can you use do-task within the .rsp page? | |
And timers? | |
Dockimbel 31-Dec-2009 [7014x2] | PHP: quite stable as long as you don't do live %httpd.cfg file reload (mess up PHP processes). do-task in RSP : no, UniServe's model is : one unique dispatcher process, one or many worker process. Timers: no, they require an event loop, worker processes can't have one because they are supposed to work in a request/response model. |
What's the need to have timers in RSP script when you have it already in socket applications? | |
Terry 31-Dec-2009 [7016] | Another question.. lets say i have two clients connected via websockets.. .remote-ports 3450 and 65480 How would i pass the message from one to the other? |
Dockimbel 31-Dec-2009 [7017] | Btw, in the current SVN revision, it's not possible to call 'do-task from 'on-timer event. |
Terry 31-Dec-2009 [7018] | Need some port managment layer I suppose. |
Dockimbel 31-Dec-2009 [7019x2] | You already have it. |
It's minimal but it should cover all needs. | |
Terry 31-Dec-2009 [7021] | What i mean is a layer that associates ips and ports with sessions, pass these on to a db etc. |
Dockimbel 31-Dec-2009 [7022x4] | The current framework gives you access to client ports value, RSP session object associated with a client, RSP script execution (with 'do-task). |
Database accesses should be done in RSP scripts (because they are usually too time-consuming). | |
Btw, if you need to keep client specific data, it's quite simple. Here's an example (untested) : users: make block! 1 session-class: context [hits: 0] on-connect: func [client][ if not find users client [ repend users [client make session-class [ ]] ] ] on-message: func [client data /local ctx][ ctx: select users client ctx/hits: ctx/hits + 1 ... ] on-deconnect: func [client][ remove/part find users client 2 ] | |
sorry: on-deconnect => on-disconnect | |
Terry 31-Dec-2009 [7026] | Ideally, I guess all the socket control scripting should be done within the 'socket-app. I was thinking this would make a great proxy to a remote server for futher processing... but how to pass the arguments? |
Dockimbel 31-Dec-2009 [7027] | Futher processing can be done in RSP scripts in worker process, that's what they are meant for. If you need to connect to a third-party server, arguments passing depends on the communication protocol required. |
Terry 31-Dec-2009 [7028x2] | I think I'm lost (happens all the time). Let's say I want to poll a remote web page for screen scraping (or remote php processing) every 2 seconds, and pass that to a specific port.. I would do this from the 'socket-app, no? |
Now lets say the client hits an event on the web page, and now i want the timer to visit a different remote web page.. how would i pass that event to the timer? | |
Dockimbel 31-Dec-2009 [7030x2] | You would generate the timer events in the socket-app, pass the job to do to an RSP script, and use the /on-done handler to send the response to the client you want once the RSP script finished its work. (this will work once I fix the issue with 'do-task calls from 'on-timer events). |
The timer is just an event generator, you can't pass data to the timer. You need to store such info in a user session (a block! or object! for example). | |
Terry 31-Dec-2009 [7032] | Ah.. i figured out where Im lost! It's at the "generate a timer event", "pass the job to an RSP script" and the "use the /on-done handler" bits :) |
Dockimbel 31-Dec-2009 [7033] | :-) |
Terry 31-Dec-2009 [7034] | Once I figure this out, I'll paste a layer on top of it for noobs like me. |
Dockimbel 31-Dec-2009 [7035] | I guess it will be more clear once I make a few demo apps and write a doc for the new API. |
Terry 31-Dec-2009 [7036x2] | I started a diagram at least http://www.gliffy.com/publish/1943806/ |
Just need to fill in the arcs :) | |
Dockimbel 31-Dec-2009 [7038x2] | Both blocks in your diagram should be on the same horizontal line, the ws.rsp block should be behind, it's part of the backend while ws-test-app.r is on the frontend. |
should => should not | |
older newer | first last |