File tree Expand file tree Collapse file tree 7 files changed +2078
-15
lines changed
src/net/tootallnate/websocket Expand file tree Collapse file tree 7 files changed +2078
-15
lines changed Original file line number Diff line number Diff line change 11* .class
22* .svn
3-
3+ * ~
Original file line number Diff line number Diff line change 1- Copyright (c) 2010 Nathan Rajlich
1+ Copyright (c) 2010-2012 Nathan Rajlich
22
33 Permission is hereby granted, free of charge, to any person
44 obtaining a copy of this software and associated documentation
Original file line number Diff line number Diff line change 11Java WebSockets
22===============
33
4- ### Note: This lib currently only supports the older draft 75 and draft 76.
5- ### Pull requests for the latests drafts would be more than accepted!
6-
74This repository contains a barebones WebSocket server and client implementation
85written in 100% Java. The underlying classes are implemented using the Java
96` ServerSocketChannel ` and ` SocketChannel ` classes, which allows for a
107non-blocking event-driven model (similar to the
118[ WebSocket API] ( http://dev.w3.org/html5/websockets/ ) for web browsers).
129
10+ Implemented WebSocket protocol versions are:
11+
12+ * [ Hixie 75] ( http://tools.ietf.org/id/draft-hixie-thewebsocketprotocol-75.txt )
13+ * [ Hixie 76] ( http://tools.ietf.org/id/draft-hixie-thewebsocketprotocol-76.txt )
14+ * [ Hybi 10] ( http://tools.ietf.org/id/draft-ietf-hybi-thewebsocketprotocol-10.txt )
15+ * [ Hybi 17] ( http://tools.ietf.org/id/draft-ietf-hybi-thewebsocketprotocol-17.txt )
16+
1317Running the Example
1418-------------------
1519
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -60,14 +60,8 @@ public enum Role{
6060 * The byte representing the end of a WebSocket text frame.
6161 */
6262 public static final byte END_OF_FRAME = (byte )0xFF ;
63-
63+
6464 public static final boolean DEBUG = false ;
65-
66- static {
67- if ( DEBUG ) {
68- System .out .println ("WebSocket debug mode enabled" );
69- }
70- }
7165
7266
7367 // INSTANCE PROPERTIES /////////////////////////////////////////////////////
Original file line number Diff line number Diff line change 88import java .util .List ;
99import java .util .Random ;
1010
11+ import net .tootallnate .websocket .Base64 ;
1112import net .tootallnate .websocket .Draft ;
1213import net .tootallnate .websocket .FrameBuilder ;
1314import net .tootallnate .websocket .Framedata ;
1617import net .tootallnate .websocket .HandshakeBuilder ;
1718import net .tootallnate .websocket .Handshakedata ;
1819import net .tootallnate .websocket .exeptions .InvalidHandshakeException ;
19- import sun .misc .BASE64Encoder ;
2020
2121
2222public class Draft_10 extends Draft {
@@ -158,7 +158,7 @@ private String generateFinalKey( String in ){
158158 } catch ( NoSuchAlgorithmException e ) {
159159 throw new RuntimeException ( e );
160160 }
161- return new BASE64Encoder (). encode ( sh1 .digest ( acc .getBytes () ) );
161+ return Base64 . encodeBytes ( sh1 .digest ( acc .getBytes () ) );
162162 }
163163
164164 @ Override
@@ -169,7 +169,7 @@ public HandshakeBuilder postProcessHandshakeRequestAsClient( HandshakeBuilder re
169169
170170 byte [] random = new byte [16 ];
171171 new Random ().nextBytes ( random );
172- request .put ( "Sec-WebSocket-Key" , new BASE64Encoder (). encode ( random ) );
172+ request .put ( "Sec-WebSocket-Key" , Base64 . encodeBytes ( random ) );
173173
174174 return request ;
175175 }
You can’t perform that action at this time.
0 commit comments