private synchronized OutputStream getSocketInputOutputStream ( int stream ) { if ( ! pipedOutput . containsKey ( stream ) ) { try { PipedInputStream pipeIn = new PipedInputStream ( ) ; PipedOutputStream pipeOut = new PipedOutputStream ( pipeIn ) ; pipedOutput . put ( stream , pipeOut ) ; input . put ( stream , pipeIn ) ; } catch ( IOException ex ) { // This is _very_ unlikely, as it requires the above constructor to fail. // don't force callers to catch, but still throw throw new IllegalStateException ( ex ) ; } } return pipedOutput . get ( stream ) ; }
Get the pipe to write data to a specific InputStream . This is called when new data is read from the web socket to send the data on to the right stream .