src/main/java/org/java_websocket/server/WebSocketServer.java
private void doBroadcast(Object data, Collection<WebSocket> clients) {
		String sData = null;
		if (data instanceof String) {
			sData = (String)data;
		}
		ByteBuffer bData = null;
		if (data instanceof ByteBuffer) {
			bData = (ByteBuffer)data;
		}
		if (sData == null && bData == null) {
			return;
		}
		Map<Draft, List<Framedata>> draftFrames = new HashMap<Draft, List<Framedata>>();
		for( WebSocket client : clients ) {
			if( client != null ) {
				Draft draft = client.getDraft();
				fillFrames(draft, draftFrames, sData, bData);
				try {
					client.sendFrame( draftFrames.get( draft ) );
				} catch ( WebsocketNotConnectedException e ) {
					//Ignore this exception in this case
				}
			}
		}
	}
private void doBroadcast(Object data, Collection<WebSocket> clients) {
		String sData = null;
		if (data instanceof String) {
			sData = (String)data;
		}
		ByteBuffer bData = null;
		if (data instanceof ByteBuffer) {
			bData = (ByteBuffer)data;
		}
		if (sData == null && bData == null) {
			return;
		}
		Map<Draft, List<Framedata>> draftFrames = new HashMap<Draft, List<Framedata>>();
		for( WebSocket client : clients ) {
			if( client != null ) {
				Draft draft = client.getDraft();
				fillFrames(draft, draftFrames, sData, bData);
				try {
					client.sendFrame( draftFrames.get( draft ) );
				} catch ( WebsocketNotConnectedException e ) {
					//Ignore this exception in this case
				}
			}
		}
	}
private void doBroadcast ( Object data , Collection < WebSocket > clients ) { String sData = null ; if ( data instanceof String ) { sData = ( String ) data ; } ByteBuffer bData = null ; if ( data instanceof ByteBuffer ) { bData = ( ByteBuffer ) data ; } if ( sData == null && bData == null ) { return ; } Map < Draft , List < Framedata > > draftFrames = new HashMap < Draft , List < Framedata > > ( ) ; for ( WebSocket client : clients ) { if ( client != null ) { Draft draft = client . getDraft ( ) ; fillFrames ( draft , draftFrames , sData , bData ) ; try { client . sendFrame ( draftFrames . get ( draft ) ) ; } catch ( WebsocketNotConnectedException e ) { //Ignore this exception in this case } } } }
Private method to cache all the frames to improve memory footprint and conversion time
@param data the data to broadcast
@param clients the clients to send the message to
Private method to cache all the frames to improve memory footprint and conversion time