public void start(IchtyometerClient client) throws IOException { Preconditions.checkNotNull(client, "client can not be null"); Preconditions.checkState(client.isOpen(), "client must be opened"); this.client = client; // get connection StreamConnection connection = client.openConnection(); // get input stream DataInputStream dataInputStream = connection.openDataInputStream(); // create the reader runnable readingRunnable = new ReadingRunnable(dataInputStream); // start the reader thread new Thread(readingRunnable).start(); if (log.isDebugEnabled()) { log.debug("Ready to read remote device..."); } }
public void start(IchtyometerClient client) throws IOException { Preconditions.checkNotNull(client, "client can not be null"); Preconditions.checkState(client.isOpen(), "client must be opened"); this.client = client; // create a service executor this.service = Executors.newSingleThreadScheduledExecutor(); // get bluetooth connection this.connection = client.openConnection(); // get input stream (to read) this.dataInputStream = connection.openDataInputStream(); // get output stream (to write) this.dataOutputStream = connection.openDataOutputStream(); // engine is ready if (log.isDebugEnabled()) { log.debug("Ready to read remote device..."); } }
while (true) { StreamConnection sc = scn.acceptAndOpen(); final RemoteDevice rd = RemoteDevice.getRemoteDevice(sc); new Thread() { public void run() { treatConnection(rd); } }.start(); } private void treatConnection(RemoteDevice rd) { DataInputStream input = sc.openDataInputStream(); DataOutputStream output = sc.openDataOutputStream(); String inMsg = input.readUTF(); while (inMsg != null) { // not sure about this stop condition... System.out.println(inMsg + " recived at " + new Date().toString()); output.writeUTF("Hey client Sent at " + new Date().toString()); output.flush(); inMsg = input.readUTF(); } }
this.inputStream = new SumpResultReader( conn.openDataInputStream() );
.getRemoteDevice(connection); BluetoothStreamReaderThreadImpl bluetoothConnection = new BluetoothStreamReaderThreadImpl( serverListener, connection.openDataInputStream(), remoteDevice); BluetoothConnectionHandler.UTIL.addConnection(bluetoothConnection);
inputStream = connection.openDataInputStream(); outputStream = connection.openDataOutputStream();