Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[ALLY] responsive gui with slow net -a way?

From: agem::crosswinds::net at: 8-Sep-2000 22:24

i just got it running, maybe an approach? based on Oberons single-threaded multi-tasking. rebol[title: "responsive gui with slow net" purpose: { Demo: /view gui, console & download running in parallel. } usage: {start script with dummi-argument as server, with no args as client. klick "hi server" then klick count while loading. enter some console-text. server has some [wait 4] to simulate slow net. BTW move the little window out of the way for some new :) } -needs: {experimental /view; how is the right need-syntax?!} comment: { Maybe this can be done with polling better? but i like this [observe-port port [todo] ] - approach } todo: { - times in observing too: [after 10 sec [do-this] ] - something like read-thru : read-background ? - cleanup factoring cleanup.. } ] either not system/script/args [ do-events: func [ "Process all View events." /only "restrict events to only a single window face" face /local flag event no-btn ] bind [ if not flag: event-port [event-port: open [scheme: 'event]] either only [ no-btn: foreach item face/pane [if item/action [break/return false] true] while [find system/view/screen-face/pane face] [ wait-all-ports event-port event: first event-port if event/face = face [ if any [all [event/type = 'up no-btn] event/type = 'close] [ hide-popup break] do event ] ] ] [ while [not empty? system/view/screen-face/pane] [ wait-all-ports event-port do first event-port ] ] if not flag [close event-port event-port: none] ] in system/view 'self ;bind ports: [] wait-all-ports: func[event-port ][ while[true][ clear listeners: [] a: ports forskip a 2 [ append listeners first a ] shouter: wait rejoin[listeners event-port] if same? event-port shouter [return] a: select ports shouter do a ] ] start-console: func[][ print "start-console" ; or pick cons dies.. cons: open/binary [scheme: 'console] observe-port cons [ probe to char! pick cons 1 ] ] observe-port: func[port action][ now-is ports port action ] remove-port: func [port /close] [ if a: find ports port [remove/part a 2] if close [system/words/close port] ] now-is: function [ "change value after key, if it is present, otherwise append both" series key value] [here] [ here: find series key either here [change/only next here value] [append series reduce [key value]] ] start-console view layout[button "quit" [quit] across cnt: label "00" button "count" [cnt/text: form 1 + load cnt/text show cnt] below button "hi server" [ message:" Client here. " client: open/no-wait tcp:// insert client message observe-port client [ a: copy client probe a either a [ if 0 < length? a [ view/new layout[area a] ] ] [remove-port/close client] ] ] ] ] ;server [ server: open tcp://:8000 input-buffer: make string! 1024 while [true] [ server-port: first server while [true] [ wait server-port read-io server-port input-buffer 1024 break ] print input-buffer wait 4 insert server-port join input-buffer [" from server."] wait 4 insert server-port "the rest" clear input-buffer close server-port ] ]