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
10-Jan-2010
[7403x5]
SVN r59 : experimental mod-upload released.  This new mod adds server-side 
API for querying realtime progress info on uploaded files. See the 
demo : http://localhost/upload.html(not commented yet).

Current restrictions:
- works only when posting one file at a time in a given <form>.

- can't make it work for IE (IE seems to have an issue with setTimeout( 
) method).
Help would be appreciated to solve or workaround the setTimeout() 
issue with IE.
If you're testing the upload demo locally, be sure to pick a file 
big enough (at least 10 Mbps). Don't worry about uploaded files, 
the target script (show.rsp) doesn't save them, so the server's copy 
will be deleted as soon as the upload is finished.
This mod-upload version is unsuitable for production yet, the upload 
tokens on server are not garbage-collected.
10 Mbps => 10MB
Terry
10-Jan-2010
[7408x2]
After updating the SVN, I get a 

 id: 'cannot-open
    arg1: "/c/websock2/Cheyenne/mods/mod-upload.r"

and the file is not there.
should have some default error trapping for socket-apps in the http.cfg 
file, no? One typo brings the whole server down.
Terry
11-Jan-2010
[7410x3]
Working on some websocket experiments.. 
http://shinyrockets.com/exper.html


- simple canvas game... Losing the game publishes the fail , ip and 
port to everybody.
I'm curious as to lag around the world (should add geocaching i suppose)
Doc, any thoughts on a standard protcol for sockets? xml?
Dockimbel
11-Jan-2010
[7413x7]
mod-upload: it was missing, it's in the repository now.
standard protocol for sockets : JSON.
take the reb-services dialecting approach and format it in JSON ;-)
Typos errors in config file should be caught, what kind of typo was 
that?
Btw, keep in mind that defining a "standard" protocol above web sockets 
goes against its primary purpose : provide a general purpose packet-oriented 
communication channel. It would be like defining a "standard" protocol 
above TCP.


For practical usage with JS clients, JSON data format is the way 
to go. Don't forget that the web socket implementation in Cheyenne 
is partial, only TEXT frames are supported currently. I could add 
the binary support also, but I don't have a need for that for now. 
If someone has a *real* need for that, let me know.
IE issue fixed with upload.html. It wasn't a settimeout( ) issue, 
it was a IE caching all the AJAX responses.
SVN r61

FEAT: added request/store function to help manage uploaded files 
(see %changelog.txt).
FIX: IE issue with upload.html (cache issue). Works ok in IE now.
DOC: upload API documented in %www/upload.html.
Terry
11-Jan-2010
[7420x5]
JSON was my first thought.. but I think I'll build a custom "data 
format" using triples to keep inline with the back end.. still thinking 
about it.
I guess the binary support would go hand in hand with your new upload 
script?
There's a blur with websockets.. traditional usage takes a form, 
serialize and send to the server as a associative array in the url.. 
With sockets, that's not necessary. 

Forms are becoming less relevant.. As individual fields can do their 
own thing.. 

<input type="text" onblur="ws.send(this.val());">
Even non-form elements can be used.. 

<p id="myparagraph"  onchange="ws.send(this.text);">
Lorem ipsum
</p>
BTW, the typo wasn't in the config file, but in my ws app,  If one 
app doesn't work, should the whole server come down?
Dockimbel
11-Jan-2010
[7425]
Binary support / upload: these are 2 different things. Uploading 
files (access to local filesystem) still requires FORM with multipart/form-data 
encoding.
Terry
11-Jan-2010
[7426x2]
Hmm, maybe not with WS?
Might even get away with partial file uploads, incrementals etc.
Dockimbel
11-Jan-2010
[7428]
WS doesn't give you access to local filesystem.
Terry
11-Jan-2010
[7429x6]
P2P
http://webkit.org/demos/sticky-notes/index.html
Another handy html 5 api..  Web pages can determine if the client 
is online. (returns boolean)

var online = navigator.onLine;
alert(online);
So, jump on a plane, update your Cheyenne data, store local, and 
sync via ws when back online :)
<script>
var online = navigator.onLine
if(online){var conn = new WebSocket("ws://localhost/ws.rsp")}
</script>
else{golocalsql();}
Dockimbel
11-Jan-2010
[7435]
Terry, sure, HTML5 opens up a new world for web applications, the 
gap with native apps is closing.
Terry
11-Jan-2010
[7436x2]
How about this..  passing a block via websocket as a data method? 
(not even sure if it would work), and loading it?
ie: ws.send("[a 'one' b 'two]");
any security issues?
BrianH
11-Jan-2010
[7438]
Not is you screen the data after loading and throw away all functions.
Terry
11-Jan-2010
[7439]
Hmm, that could be very handy.
BrianH
11-Jan-2010
[7440]
It requires more security screening than JSON on the server side, 
and more work on the client side.
Terry
11-Jan-2010
[7441]
But, it is rebol friendly
BrianH
11-Jan-2010
[7442x3]
Not for web clients. You have to assume the client is hostile for 
web stuff, and screening REBOL data for malicious stuff is harder 
than parsing JSON data. The only way to be safe is to not transmit 
an executable dialect - full data dialect, reject anything bad.
It's great if the client won't primarily be a browser, as long as 
you stick to full dialects and never DO the code.
Fortunately you can't create reference loops without DO, so if you 
stick to LOAD/all you should be fine.
Terry
11-Jan-2010
[7445x6]
Here's some JS that takes an array of elements, and builds a block 
for passing to Rebol via WS

<script>
function toblock(arr){
	var block = '[';

	jQuery.each(arr, function(){
		var val = $(this).val();
		var id = $(this).attr('id');
		block = block+id+" '"+val+"' ";
		
	});
	
	block = block+"]";
	
	//remove, 
	alert(block);
};
<script>

<input id="one" type="text" />
<input id="two" type="text" />

 <button onclick="toblock([one, two]);">TEST</button>
oops.. missing / in closing script tag
That function only deals with elements that have value attributes.. 
for pulling the content of, say a <p>, use this.. 

jQuery.each(arr, function(){
		var val = $(this).val();
		if(val== ''){val = $(this).text();}
		......
if you want the html... 
if(val== ''){val = $(this).html();}
Why does this work

>> n: "one 'on' two 'tw'"
== "one 'on' two 'tw'"
>> x: to-block n
== [one 'on' two 'tw']
>> x/one
== 'on'

but not this (data is from ws)

r: to-block data
r/one
I can't turn data into a block no matter what i try?
PeterWood
11-Jan-2010
[7451]
Terry, are you mixing 1 and one ?
PeterWood
12-Jan-2010
[7452]
>> x/one
== 'on'
>> x/1
== one

x/one is really a shortcut for select x 'one:

>> select x 'one
== 'on'