Commit 87d278d3 authored by Bernd Paysan's avatar Bernd Paysan

Some refactoring

parent 7ae5626a
......@@ -572,18 +572,12 @@ compsem: ['] net2o-code0 compile, also net2o-base ;
buf# min-size I lshift u<= IF
I outflag @ stateless# and IF send-cX ?punch-cmds
ELSE
send-reply >r over buf# r@ 2!
r> action-of send-xt ?dup-IF execute
ELSE 2drop <err> ." send-xt is 0" cr <default> THEN
send-reply >r over buf# r@ 2! r> send-xt
THEN
min-size I lshift UNLOOP
64r> dest-addr 64! EXIT THEN
LOOP 64r> dest-addr 64! true !!commands!! ;
[IFUNDEF] ftime
: ftime ( -- r ) ntime d>f 1e-9 f* ;
[THEN]
: cmd ( -- ) cmdbuf# @ 1 u<= ?EXIT \ don't send if cmdbuf is empty
connection >o outflag @ >r cmdbuf$ cmddest
avalanche( ." send cmd: " ftime 1000e fmod (.time) 64dup x64. 64>r dup hex. 64r> cr )
......
......@@ -588,10 +588,7 @@ previous
: end-code| ( -- ) ]] end-code client-loop [[ ; immediate compile-only
: gen-request ( -- )
setup! +resend-cmd gen-tmpkeys ['] connect-rest rqd?
cmd( ind-addr @ IF ." in" THEN ." direct connect" forth:cr )
ivs( ." gen request" forth:cr )
: connect-request ( -- )
net2o-code0
net2o-version $, version? 0key,
tpkc keysize $, receive-tmpkey
......@@ -600,7 +597,13 @@ previous
ind-addr @ IF punch? THEN
req-codesize req-datasize map-request, close-tmpnest
['] push-cmd IS expect-reply?
end-code| ;
end-code ;
: gen-request ( -- )
setup! +resend-cmd gen-tmpkeys ['] connect-rest rqd?
cmd( ind-addr @ IF ." in" THEN ." direct connect" forth:cr )
ivs( ." gen request" forth:cr )
connect-request client-loop ;
in net2o : connect ( ucode udata -- ) reqsize! gen-request ;
......
......@@ -1075,21 +1075,21 @@ in net2o : punch ( addr u o:connection -- )
ELSE 2drop THEN ;
: punch-wrap ( xt -- )
return-address $10 $make { w^ ret } catch
ret $@ return-address $10 smove
ret $free throw ;
return-address { ret[ $10 ] } catch
ret[ return-address $10 move throw ;
: punch-loop ( xt -- )
[{: xt :}l punch-addrs $@ bounds ?DO
I @ xt addr>sock
cell +LOOP ;] punch-wrap ;
: pings ( o:connection -- )
\G ping all addresses (why except the first one?)
[: punch-addrs $@ bounds ?DO
I @ ['] ping-addr1 addr>sock
cell +LOOP ;] punch-wrap ;
['] ping-addr1 punch-loop ;
: punchs ( addr u o:connection -- )
\G send a reply to all addresses
[: punch-addrs $@ bounds ?DO
I @ ['] send-punch addr>sock
cell +LOOP ;] punch-wrap 2drop ;
['] send-punch punch-loop ;
\ send chunk
......
......@@ -61,9 +61,6 @@ Sema notify-sema
[ELSE]
[IFDEF] linux
require linux/notify.fs
[IFUNDEF] ftime
: ftime ( -- r ) ntime d>f 1e-9 f* ;
[THEN]
[THEN]
: show-notification ( -- )
......
......@@ -520,6 +520,8 @@ previous
\ print time
: ftime ( -- r ) ntime d>f 1e-9 f* ;
64Variable tick-adjust
: ticks ( -- u64 ) ntime d>64 tick-adjust 64@ 64+ ;
......
# Commands #
Version 0.9.1-20190926.
Version 0.9.1-20191003.
net2o separates data and commands. Data is passed through to higher
layers, commands are interpreted when they arrive. For connection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment