I understand that StreamingService is deprecated in JME3 for architectural reasons. I’m interested in streaming resources (propriatary files and assets) from the server to the client. Has anyone found a nice way of doing this in SpiderMonkey?
This was left out of SpiderMonkey because there is no way that we will ever be even 10% as efficient as a web server for serving data in this way. Also, this sort of networking API is inherently “push” and streams are inherently “pull”.
Still, if you require this and cannot use a web server to make your data available, it isn’t hard to cobble something together to break your data up into multiple messages. If you want it to behave like an InputStream then that’s where the work will be.
It would be tempting to use PipeInputStream and PipeOutputStream but I can tell you from experience that they have nasty blocking behavior when the internal buffer is full. It would be better to write your own InputStream backed by a ConcurrentLinkedQueue of byte arrays and take() a new buffer when your current buffer runs out. The messages coming from the server can simply add their contained bytes right to this queue. Include an index and total count in your messages or send an empty byte to indicate end of file.