Index: openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl,v diff -u -r1.68 -r1.68.2.1 --- openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl 16 Nov 2018 18:39:51 -0000 1.68 +++ openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl 23 Feb 2019 19:02:55 -0000 1.68.2.1 @@ -287,7 +287,7 @@ set ::subscription_count 0 set ::message_count 0 - ::xotcl::Class create Subscriber -parameter {key channel user_id mode} + ::xotcl::Class create Subscriber -parameter {key channel user_id mode {start_of_page ""}} Subscriber proc current {-key } { set result [list] if {[info exists key]} { @@ -338,16 +338,8 @@ Subscriber instproc send {msg} { #ns_log notice "SEND <$msg> [:mode]" :log "" - if {[:mode] eq "scripted"} { - ::sec_handler_reset - set emsg [encoding convertto utf-8 $msg] - #ns_log notice "SEND data <$msg> encoded <$emsg>" - set smsg "\n" - set smsg [format %x [string length $smsg]]\r\n$smsg\r\n - } else { - set smsg $msg - } + ::sec_handler_reset + set smsg [::xo::mr::bgdelivery encode_message [:mode] $msg] #my log "-- sending to subscriber for [:key] $smsg ch=[:channel] \ # mode=[:mode], user_id [:user_id]" try { @@ -362,7 +354,7 @@ "POSIX ECONNRESET {connection reset by peer}" } if {$::errorCode in $ok_errors} { - throw {CLIENTDISCONNECT} {client disconnected} + throw {AD_CLIENTDISCONNECT} {client disconnected} } else { throw $::errorCode $errorMsg } @@ -376,7 +368,7 @@ foreach s [set :subscriptions($key)] { try { $s $method $argument - } trap {CLIENTDISCONNECT} {errMsg} { + } trap {AD_CLIENTDISCONNECT} {errMsg} { ns_log warning "$method to subscriber $s (key=$key): $errMsg" $s destroy } on error {errMsg} { @@ -411,22 +403,8 @@ #my log "-- cl=[:info class], subscriptions([:key]) = $subscriptions([:key])" fconfigure [:channel] -translation binary - if {[:mode] eq "scripted"} { - set content_type "text/html;charset=utf-8" - set encoding "Cache-Control: no-cache\r\nTransfer-Encoding: chunked\r\n" - set body "[string repeat { } 1024]\r\n" - set body [format %x [string length $body]]\r\n$body\r\n - } else { - # Chrome refuses to expose partial response to ajax unless we - # set content_type to octet stream. Drawback is we have to - # force the translation on the channel. - set content_type "application/octet-stream" - set encoding "" - fconfigure [:channel] -encoding utf-8 - set body "" - } - - puts -nonewline [:channel] "HTTP/1.1 200 OK\r\nContent-type: $content_type\r\n$encoding\r\n$body" + fconfigure [:channel] -encoding utf-8 + puts -nonewline [:channel] ${:start_of_page} flush [:channel] } @@ -769,14 +747,14 @@ } ##################################### -bgdelivery proc subscribe {key {initmsg ""} {mode default} } { +bgdelivery proc -deprecated subscribe {key {initmsg ""} {mode default} } { set ch [ns_conn channel] thread::transfer [:get_tid] $ch #my do ::Subscriber sweep $key :do ::Subscriber new -channel $ch -key $key -user_id [ad_conn user_id] -mode $mode } -bgdelivery proc send_to_subscriber {key msg} { +bgdelivery proc -deprecated send_to_subscriber {key msg} { :do -async ::Subscriber broadcast $key $msg } #####################################