Index: openacs-4/packages/xowiki/tcl/chat-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/chat-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/xowiki/tcl/chat-procs.tcl 8 Apr 2006 15:00:44 -0000 1.6 +++ openacs-4/packages/xowiki/tcl/chat-procs.tcl 9 Apr 2006 00:07:10 -0000 1.7 @@ -6,7 +6,7 @@ @cvs-id $Id$ } namespace eval ::xowiki { - ::xo::ChatClass Chat -superclass ::xo::Chat + ::xo::ChatClass Chat -superclass ::xo::Chat Chat instproc render {} { my orderby time @@ -43,22 +43,35 @@ if {![info exists mode]} { set mode polling - set user_agent [string tolower [ns_set get [ns_conn headers] User-Agent]] - if {[regexp (firefox) $user_agent] && [info command ::thread::mutex] ne ""} { - set mode streaming + if {[info command ::thread::mutex] ne ""} { + # we seem to have libthread installed, we can use the background delivery thread + # scripted streaming should work everywhere + set mode scripted-streaming + if {[regexp (firefox) [string tolower [ns_set get [ns_conn headers] User-Agent]]]} { + # for firefox, we could use the nice mode without the spinning load indicator + set mode streaming + } } - my log "--mode $mode, user_agent=$user_agent" + my log "--mode $mode" } - - if {$mode eq "polling"} { - ::xowiki::Page requireJS "/resources/xowiki/get-http-object.js" - set jspath packages/xowiki/www/ajax/chat.js - set login_url ${path}ajax/chat?m=login&$context - set get_update "chatSendCmd(\"$path/ajax/chat?m=get_new&$context\",chatReceiver)" - set get_all "chatSendCmd(\"$path/ajax/chat?m=get_all&$context\",chatReceiver)" - } else { - set jspath packages/xowiki/www/ajax/streaming-chat.js - set subscribe_url ${path}ajax/chat?m=subscribe&$context + + switch $mode { + polling { + ::xowiki::Page requireJS "/resources/xowiki/get-http-object.js" + set jspath packages/xowiki/www/ajax/chat.js + set login_url ${path}ajax/chat?m=login&$context + set get_update "chatSendCmd(\"$path/ajax/chat?m=get_new&$context\",chatReceiver)" + set get_all "chatSendCmd(\"$path/ajax/chat?m=get_all&$context\",chatReceiver)" + } + streaming { + set jspath packages/xowiki/www/ajax/streaming-chat.js + set subscribe_url ${path}ajax/chat?m=subscribe&$context + } + scripted-streaming { + append context &mode=scripted + set jspath packages/xowiki/www/ajax/scripted-streaming-chat.js + set subscribe_url ${path}ajax/chat?m=subscribe&$context + } } set send_url ${path}ajax/chat?m=add_msg&$context&msg= @@ -67,22 +80,20 @@ } set file [open [acs_root_dir]/$jspath]; set js [read $file]; close $file - if {$mode eq "polling"} { - return "\ + switch $mode { + polling {return "\
-
- " - } else { - return "\ + " + } + streaming {return "\ +
+ +
+ +
" + } } } }