Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
  *
  * The software in this package is published under the terms of the CPAL v1.0
  * license, a copy of which has been included with this distribution in the
  * LICENSE.txt file.
  */
 package com.sitewhere.device.communication.socket;
 
Implementation of com.sitewhere.spi.device.communication.socket.ISocketInteractionHandler that reads everything from the socket and sends the resulting byte array to the parent event source.

Author(s):
Derek
public class ReadAllInteractionHandler implements ISocketInteractionHandler<byte[]> {
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.communication.socket.ISocketInteractionHandler#process
	 * (java.net.Socket, com.sitewhere.spi.device.communication.IInboundEventReceiver)
	 */
	public void process(Socket socketIInboundEventReceiver<byte[]> receiverthrows SiteWhereException {
		try {
			InputStream input = socket.getInputStream();
			int value;
			while ((value = input.read()) != -1) {
				output.write(value);
			}
			input.close();
catch (IOException e) {
			throw new SiteWhereException("Exception processing request in socket interaction handler."e);
		}
	}

Factory class that produces ReadAllInteractionHandler instances.

Author(s):
Derek
	public static class Factory implements ISocketInteractionHandlerFactory<byte[]> {
		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * com.sitewhere.spi.device.communication.socket.ISocketInteractionHandlerFactory
		 * #newInstance()
		 */
		}
	}
New to GrepCode? Check out our FAQ X