r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!Cheyenne] Discussions about the Cheyenne Web Server

Dockimbel
31-Dec-2009
[7046x3]
That comes from the way web socket's connection are initiated, it 
starts like a simple HTTP GET request and the server is supposed 
to validate that request, check access authorization if required, 
etc... So, to avoid duplicating work, I choose to re-use RSP framework 
as much as possible. The initial ws:// URL must point to a valid 
RSP script so that the server can check, for example, RSP session 
cookie for access rights.
So, during the connection time, the target RSP script is not executed 
(unless you pass it a 'do-task in the 'on-connect handler). This 
target RSP gets associates with the opened socket until it's closed.
/on-done installs a callback handler (block! or function!) that gets 
invoked when the job sent by 'do-task to the RSP script is finished.
Terry
31-Dec-2009
[7049x2]
How do you pass a do-task to an rsp script? (what variables are passed?)
must it be the initial rsp script?
Dockimbel
31-Dec-2009
[7051]
do-task takes a string! argument. You can pass anything you want 
using that value.
Terry
31-Dec-2009
[7052]
I put that "do %test.r"   in the timer without using do-task.. and 
it worked fine.. i guess that was blocking though?
Dockimbel
31-Dec-2009
[7053x3]
You can also use the 'rsp-session object to permanently share values 
with the RSP process (to be usage carefully, see %ws-test-app.r).
I've fixed several issues with timers, so yes probably. I still don't 
get why you want to "do" a script on each event...
to be usage => to be used
Terry
31-Dec-2009
[7056x3]
i was just experimenting.
(as far as putting the "do" in the timer)
As for "do"ing a script with each event, I suppose the traditional 
way would be put all your code in the ws.app.r ... do ing was more 
like "include"
Dockimbel
31-Dec-2009
[7059]
The last revision will auto-load your socket app if you've modified 
it, but only new incoming connections will use it. Established connection 
will still use the older version. Once every client disconnects from 
the old version, the old app version is dropped out.
Terry
31-Dec-2009
[7060x6]
Ok.. i'm officially digging Cheyenne's websockets
some examples coming down the pipe
Here's a modified on-message from ws-test-app.r 

	on-message: func [client data][						
		;send data
					
		do-task/on-done data func [client data][	 
		

   ;data: do/args %/c/cheyenne/cheyenne/test.r {one "two three"}		  
       ;doing a script passing /args

   data: read http://www.php.net/usage.php				      ;as 
   a proxy to PHP server
			
			send/with data client
		]
	]
and the test.r script... (drop in Cheyenne's root)

rebol []
 
x: to-block system/script/args
 
to-string x/test
opps, change last line of test.r to 

to-string x/one
Here's a little demo that allows you to drag an image, and once you 
stop dragging, sends it's position to a .r script via a socket. The 
script then sends a message to another image on the page to reset 
it's top and left position to match the dragged image, +100 px

The updated ws2.html page

http://pastebin.com/m4f61ffd7

the updated ws-test-app.r 

http://pastebin.com/m7c39d7c6

and the test.r script is (place in the Chyenne root)

rebol []
 
x: to-block system/script/args
 
left: x/left + 100 
top: x/top + 100

left: join left "px"
top: join top "px" 
 

data: rejoin [{$('#carl2').css("top", "} top {");} {$('#carl2').css("left", 
"} left {");}]
Terry
1-Jan-2010
[7066]
Demo

http://shinyrockets.com/ws2.html
btiffin
1-Jan-2010
[7067]
Sorry Terry.  The shinyrockets link leads to a godaddy parked page 
from here.
Terry
1-Jan-2010
[7068x2]
cached
Added an "easing" effect to demo
Graham
1-Jan-2010
[7070x3]
Alternate upgrade method .. download binary patch, read the current 
version, xor it, write it out as the new version .. and then the 
same as in your script above.
Terry's demo http://70.68.163.178/ws2.html

Doesn't work for me .. when I reach that page, it says "socket closed"
Dragging the image doesn't do anything.
I think's because the source refers to shinyrockets ...
amacleod
1-Jan-2010
[7073]
Works for me
Graham
1-Jan-2010
[7074]
what works for you?
amacleod
1-Jan-2010
[7075]
terry's demo page
Paul
1-Jan-2010
[7076]
When I go to it it shows Carl's picture twice with one that says 
"drag me" under it.  But when I try to drag it - it does nothing. 
 This is on IE8 and also on Chrome.
Graham
1-Jan-2010
[7077x2]
Needs Chrome 4
What exactly works for you ?  What are you doing and what happens?
amacleod
1-Jan-2010
[7079x2]
I can drag image
other image turns darker when click/dragged
I do get socket closed message too
Graham
1-Jan-2010
[7081]
in other words it is not working for you.
amacleod
1-Jan-2010
[7082]
Sorry, I thought the draggable picture was the demo
Janko
1-Jan-2010
[7083]
I don't have XP here , so I can't try chrome .. does anyone know 
when websockets are comming to other browsers? I heard some svn version 
of FF has it to and lately I heard of devel version of Webkit (I 
assume safari) also
Graham
1-Jan-2010
[7084x3]
No, that's just Jquery
What is supposed to happen is that when you drop the image, a message 
is sent to the socket and then some javascript executes to move the 
other image next to the one you drop .. something like that.
but the socket pointed to is on shinyrockets which is just a bigdaddy 
place holder page
Graham
3-Jan-2010
[7087]
How's the chat server demo ?
Will
3-Jan-2010
[7088]
is there a chat demo? where?
Graham
3-Jan-2010
[7089]
doc is going to create some type of demo using web sockets
Will
3-Jan-2010
[7090x3]
I'm upgrading my cheyenne, have to try this websockets stuffs, btw, 
nightly webkit also supports websockets (download here http://nightly.webkit.org/)
here is the only websockets demo I found online http://orbited.org/wiki/LiveHelp
here is a flash based websocket so you can support old browsers and 
use websockets now 8-)  http://github.com/gimite/web-socket-js
Dockimbel
3-Jan-2010
[7093]
My demo is ready, but I found an issue to fix first with HTTP keepalive 
connections timeout colliding with web sockets timeout. The demo 
should be ready to try in a couple of hours (lunch time here).
Will
3-Jan-2010
[7094]
here is jQuery websocket plugin and chat demo that I will try to 
make work with Cheyenne
Graham
3-Jan-2010
[7095]
Midnight here ... I'll check it out tomorrow!