... | ... | @@ -32,6 +32,15 @@ To implement the dispatch, the messages (or chunks) are sent in the following se |
|
|
|
|
|
The messages or chunks are sent through the stream. After the message reading, the read handler name allows to dispatch it to the correct handler. The *StreamDispatcher* object is responsible for collecting and forwarding the message to the correct handler. There is one *StreamDispatcher* on the client side and as many as clients on the server side.
|
|
|
|
|
|
#### API
|
|
|
|
|
|
The main functions of *StreamDispatcher* are:
|
|
|
* stringCollector: Returns a stream and calls the callback with the resulting string.
|
|
|
* stringCollectorGenerator: Generates generic writable streams, transforming the received data in a string which is forwarded to a callback when completely received.
|
|
|
* setHandler: Fills a writable stream when data is received at the corresponding handler.
|
|
|
* sendString: Sends a string to a specific handler.
|
|
|
* sendStream: Sends a stream.
|
|
|
|
|
|
#### Limitations and improvements
|
|
|
|
|
|
For big data, we do not know the number of chunks that will be sent to the client (the chunks are read from another file stream). Then the current protocol searches in each chunk the presence of the end sequence by comparing the bytes. When it is found, the response is considered finished.
|
... | ... | |