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.4 -r1.5 --- openacs-4/packages/xowiki/tcl/chat-procs.tcl 31 Mar 2006 19:36:45 -0000 1.4 +++ openacs-4/packages/xowiki/tcl/chat-procs.tcl 8 Apr 2006 00:11:53 -0000 1.5 @@ -33,45 +33,75 @@ Chat proc initialize_nsvs {} {;} ;# noop - Chat proc login {-chat_id -package_id} { + Chat proc login {-chat_id -package_id -mode} { + my log "--" auth::require_login - ::xowiki::Page requireJS "/resources/xowiki/get-http-object.js" if {![info exists package_id]} {set package_id [ad_conn package_id] } if {![info exists chat_id]} {set chat_id $package_id } - set context id=$chat_id&s=[ad_conn session_id].[clock seconds] - set path packages/xowiki/www/ajax/chat.js - if { ![file exists [acs_root_dir]/$path] } { - return -code error "File [acs_root_dir]/$path does not exist" + set path [site_node::get_url_from_object_id -object_id $package_id] + + if {![info exists mode]} { + set mode polling + set user_agent [string tolower [ns_set get [ns_conn headers] User-Agent]] + if {[regexp (firefox|msie) $user_agent] && [info command ::thread::mutex] ne ""} { + set mode streaming + } + my log "--mode $mode, user_agent=$user_agent" } - set file [open [acs_root_dir]/$path]; set js [read $file]; close $file - set location [util_current_location] - set path [site_node::get_url_from_object_id -object_id $package_id] - set login_url $path/ajax/chat?m=login&$context - set send_url $path/ajax/chat?m=add_msg&$context&msg= - set get_update "chatSendCmd(\"$path/ajax/chat?m=get_new&$context\",chatReceiver)" - set get_all "chatSendCmd(\"$path/ajax/chat?m=get_all&$context\",chatReceiver)" - return "\ + + 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 + } + set send_url ${path}ajax/chat?m=add_msg&$context&msg= + + if { ![file exists [acs_root_dir]/$jspath] } { + return -code error "File [acs_root_dir]/$jspath does not exist" + } + set file [open [acs_root_dir]/$jspath]; set js [read $file]; close $file + + if {$mode eq "polling"} { + return "\ -
" + } else { + return "\ + + +