diff options
| author | Omar Rizwan <omar@omar.website> | 2023-11-21 18:34:26 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2023-11-21 18:34:26 +0000 |
| commit | 9c40b918eb12f50fc56a82e9957b4b0577b3341d (patch) | |
| tree | e64c5d22897d7bbf4b6b331ed9755c254f871f42 /virtual-programs | |
| parent | programs: Expose web printed-programs/; fault to folk0 (diff) | |
| download | folk-9c40b918eb12f50fc56a82e9957b4b0577b3341d.tar.gz folk-9c40b918eb12f50fc56a82e9957b4b0577b3341d.zip | |
print: Hack to forward Hex House print requests to folk0
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/print.folk | 25 |
1 files changed, 25 insertions, 0 deletions
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} |
