Package chatroom.connection

Examples of chatroom.connection.Connection


    public void onConnection(SocketChannel channel) throws IOException {
        PipedInputStream is = new PipedInputStream();
        final PipedOutputStream os = new PipedOutputStream(is);

        userNum++;
        Connection cnt = new Connection(channel) {

            @Override
            protected void onRead(byte[] data, int size) {
                try {
                    os.write(data, 0, size);
                    os.flush();
                } catch (IOException ex) {
                    logger.info("Audio reading error");
                }
            }

            @Override
            public void end() {
                super.end();
                try {
                    os.close();
                } catch (IOException ex) {
                    Logger.getLogger(AudioServer.class.getName()).log(Level.SEVERE, null, ex);
                }
                userNum--;
                if (userNum == 0) {
                    logger.info("Audio server closing...");
                    stopServer();
                }
            }
        };
        synchronized (audioList) {
            audioList.add(new MyAudioInputStream(is, AudioConfig.audioFormat, AudioSystem.NOT_SPECIFIED, cnt));
        }
        cnt.start();
    }
View Full Code Here

TOP

Related Classes of chatroom.connection.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.