From 9c40b918eb12f50fc56a82e9957b4b0577b3341d Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Tue, 21 Nov 2023 13:34:26 -0500 Subject: print: Hack to forward Hex House print requests to folk0 --- virtual-programs/print.folk | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'virtual-programs') diff --git a/virtual-programs/print.folk b/virtual-programs/print.folk index 44a7d433..6197bdd1 100644 --- a/virtual-programs/print.folk +++ b/virtual-programs/print.folk @@ -174,8 +174,27 @@ proc nextId {} { set id } +proc remotePrintRequest {remoteNode clause} { + ::websocket::open "ws://$remoteNode.local:4273/ws" [list apply {{clause sock type msg} { + if {$type eq "connect"} { + ::websocket::send $sock text [list apply {{clause} { + Assert {*}$clause + after 5000 [list Retract {*}$clause] + Step + }} $clause] + after 10000 [list ::websocket::close $sock] + } + }} $clause] +} + if {![info exists ::printjobs]} {set ::printjobs [dict create]} When /someone/ wishes to print /code/ with job id /jobid/ { + if {$::thisNode eq "folk-beads" || $::thisNode eq "folk-convivial"} { + # HACK: Forward the print request to folk0. + remotePrintRequest "folk0" [list $::thisNode wishes to print $code with job id $jobid] + return + } + puts "Wish to print jobid $jobid" if {[dict exists $::printjobs $jobid]} {return} @@ -205,6 +224,12 @@ When /someone/ wishes to print /code/ with job id /jobid/ { exec lpr $::env(HOME)/folk-printed-programs/$id.pdf } When /someone/ wishes to print program /id/ with code /code/ with job id /jobid/ { + if {$::thisNode eq "folk-beads" || $::thisNode eq "folk-convivial"} { + # HACK: Forward the print request to folk0. + remotePrintRequest "folk0" [list $::thisNode wishes to print program $id with code $code with job id $jobid] + return + } + puts "Wish to print jobid $jobid" if {[dict exists $::printjobs $jobid]} {return} -- cgit v1.2.3