* various fixes to readable-stream implementation using blocking srt calls.
- refactor reading/pushing routine in order to allow higher througput:
* call srt read() in the same tick/stack as the class _read impl call
* schedule a timer only as needed if no connection yet or socket buffer empty
* blocking loop to push all bytes requested, or until push returns false
or until no more data is in the socket buffer
* generally, handle case properly where no data is yet available from srt-socket read()
* in case no more data, retains the currently requested value remainder
from last _read call
-> this will allow for getting as much data as requested (if socket delivers
it) within the tick where it was requested or any next one in a best effort
manner. it will block the main-thread with "too long" execution frames/ticks
eventually as the data-demand from the _read calls becomes high
in amout/frequency.
but that is simply a consequence of the fact the SRT calls here are
blocking I/O. the previous implementation was also resulting in this
congestion of the main loop queue as read calls would block it, but at best
there was a 100ms lag between a request for read and its actual fulfillment.
one further improvement of this fix could be to split up the requested bytes
amount onto several ticks (executing one partial read directly, and further
ones in further timer scheduled calls, in order to avoid blocking ticks).
- use 50ms timer default for read continuation retry timer
- use 50ms interval for initial connection epoll'ing
- use consts for all timeout values
- implement base class _destroy method & refactor close() in consequence
- trigger Stream base class "readable" event on connection and first packet
* server: add an event for when a client was accepted to pass the fd
* fix lint errors in eslint config :)
* index.d.s: add /* eslint-disable @typescript-eslint/triple-slash-reference */
* improve eslint calling script
* add async-worker version of the SRT JS API with await/Promise support
+ potentially out-of-order RPC-back/result-dequeuing is possible
with a type of call-ID generator and callback-map that we prototyped
(but not used atm since the worker is only doing sync/blocking internally
with the current SRT lib binding).
* add various examples for async API ("classic" callbacks / Promise / await)
* add .eslintignore (should go with commit where we just call "eslint .")
* index.js: add missing semi
* async.js: fix method name litteral in epollUWait
* async.js: allow for accept method to use a timeout opt (defaults to false),
and a custom timeout value option (default to default timeout),
which can potentially be set differently than the general default timeout.
+ make the timeout value a static class property so that it can be
user-defined module-load wide. defaults to constant in module top scope.
* async.js: fix for a rejected promise, make sure we don't resolve anymore
+ add a custom timeout value argument to _createAsyncWorkPromise
* async.js: rm an experiment
* fix a lint error in example
* add types for async api and fix some details on binding API types
* export async API to index
* async.js: add some missing docs for private methods
* include async types in index
* add typescript definition files for this JS API
* server.js: replace console.log by debug() call
* server.js: set "iface" and "port" properties on SRTServer listen call
+ and init them with null in constructor
* stream.js: SRTReadStream: init fd property with null in constructor
* stream.js: SRTReadStream: add close method (to free the fd aquired with
connect()), likewise the writable stream methods
* example files: add "use strict"; directive on all
* examples/srt.js: correctly state variable fhandle (this would crash in strict mode
otherwise)
* NAPI: NodeSRT::GetSockOpt: fix error handling to really reach ThrowAsJavaScriptException
* add example: srt.ts (TypeScript usage)
* add .editoconfig to project root (helps keeping files free of whitespaces
and maintain indentation etc)
* package.json: improve metadata quality (via npm init call)
* package.json: add dev-deps for tsc/ts-node and node type-defs
* package.json: add check-tsc script to compile typescript example
* gitignore: add tsc-lib (typescript compiler test output)
* add tsconfig.json (typescript compiler config)
* some end-of-file newline and whitespace fixes
* stream.js: add const decls for all the magic numbers in SRTReadStream
* enable eslint static analysis to find possible issues upfront
+ and maintain codestyle
* update package-lock
* stream.js: fix whitespace and eof
* add lint script for src, examples and types modules
* types: lint error fix
This commit adds Windows build support by utilizing vcpkg to build
dependencies, and CMake for the build system.
These changes rely on vcpkg to be built and located in the VCPKG_ROOT
environment variable, along with having Visual Studio 2019 installed.