spl/server.spl
2024-09-09 16:31:35 +02:00

64 lines
1.1 KiB
Text

"#net.spl" import
"#stream.spl" import
"server" net:register
construct net:server namespace {
ServerStream
Type
_Types
types
;
Types { _Types | with this ;
this:_Types:new
}
register-type { | with id this ;
this:types id awrap aadd this:=types
id this:_Types dyn-def-field;
}
}
0 anew net:server:=types
construct net:server:Type {
id
;
construct { this | with id this ;
id this:=id
this
}
create { ServerStream | with this ;
this:id net:server:ServerStream:new
}
}
construct net:server:_Types {
;
construct { this | with this ;
{ | with type ;
"type net:server:Type:new this:=<type>";
(type net:server:Type:new) (this ("=" type concat)) dyn-objcall
} net:server:types:foreach;
this
}
}
"tcp" net:server:register-type
construct net:server:ServerStream {
id
;
construct { this | with type this ;
type new-server-stream this:=id
this
}
accept { Stream | with this ;
def stream null Stream settype =stream
this:id accept-server-stream stream:=id
stream
}
close { | with this ;
this:id close-server-stream;
}
}