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.websocket;
 
Implementation of WebSocketEventReceiver that operates on binary payloads.

Author(s):
Derek
public class BinaryWebSocketEventReceiver extends WebSocketEventReceiver<byte[]> {

Static logger instance
	private static Logger LOGGER = Logger.getLogger(BinaryWebSocketEventReceiver.class);
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.device.communication.websocket.WebSocketEventReceiver#
	 * getWebSocketClientClass()
	 */
	public Class<? extends EndpointgetWebSocketClientClass() {
		return BinaryWebSocketClient.class;
	}

Implementation of WebSocketClient that operates on byte[] payloads.

Author(s):
Derek
	public static class BinaryWebSocketClient extends Endpoint {
		/*
		 * (non-Javadoc)
		 * 
		 * @see javax.websocket.Endpoint#onOpen(javax.websocket.Session,
		 * javax.websocket.EndpointConfig)
		 */
		public void onOpen(Session sessionfinal EndpointConfig config) {
				@SuppressWarnings("unchecked")
				public void onMessage(ByteBuffer payload) {
					IInboundEventReceiver<byte[]> receiver =
					receiver.onEventPayloadReceived(payload.array());
				}
			});
		}
		/*
		 * (non-Javadoc)
		 * 
		 * @see javax.websocket.Endpoint#onClose(javax.websocket.Session,
		 * javax.websocket.CloseReason)
		 */
		public void onClose(Session sessionCloseReason closeReason) {
			.info("Web socket closed.");
		}
		/*
		 * (non-Javadoc)
		 * 
		 * @see javax.websocket.Endpoint#onError(javax.websocket.Session,
		 * java.lang.Throwable)
		 */
		public void onError(Session sessionThrowable e) {
			.error("Web socket error."e);
		}
	}
New to GrepCode? Check out our FAQ X