Skip to content

Commit c074a94

Browse files
committed
Removed duplicated code from broadcast methods
1 parent 135b3c6 commit c074a94

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

src/main/java/org/java_websocket/server/WebSocketServer.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -829,24 +829,7 @@ public void broadcast(byte[] data, Collection<WebSocket> clients) {
829829
if (data == null || clients == null) {
830830
throw new IllegalArgumentException();
831831
}
832-
Map<Draft, List<Framedata>> draftFrames = new HashMap<Draft, List<Framedata>>();
833-
ByteBuffer byteBufferData = ByteBuffer.wrap( data );
834-
synchronized( clients ) {
835-
for( WebSocket client : clients ) {
836-
if( client != null ) {
837-
Draft draft = client.getDraft();
838-
if( !draftFrames.containsKey( draft ) ) {
839-
List<Framedata> frames = draft.createFrames( byteBufferData, false );
840-
draftFrames.put( draft, frames );
841-
}
842-
try {
843-
client.sendFrame( draftFrames.get( draft ) );
844-
} catch ( WebsocketNotConnectedException e ) {
845-
//Ignore this exception in this case
846-
}
847-
}
848-
}
849-
}
832+
broadcast(ByteBuffer.wrap(data), clients);
850833
}
851834

852835
/**

0 commit comments

Comments
 (0)