-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.jwzhangjie.andbase.doc; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.java_websocket.drafts.Draft_17; | ||
|
||
import com.jwzhangjie.andbase.net.JieWebSocket; | ||
|
||
/** | ||
* title: WebSocketUsed.java | ||
* @author jwzhangjie | ||
* Date: 2014-12-6 下午3:37:12 | ||
* version 1.0 | ||
* {@link http://blog.csdn.net/jwzhangjie} | ||
* Description: JieWebSocket的简单使用,主要还是在JieWebSocket内容处理相关内容 | ||
*/ | ||
public class WebSocketUsed { | ||
|
||
private JieWebSocket mJieWebSocket; | ||
|
||
public WebSocketUsed() { | ||
try { | ||
mJieWebSocket = new JieWebSocket(new URI("url"), new Draft_17()); | ||
mJieWebSocket.connect(); | ||
} catch (URISyntaxException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.jwzhangjie.andbase.net; | ||
|
||
import java.net.URI; | ||
import java.util.Map; | ||
|
||
import org.java_websocket.client.WebSocketClient; | ||
import org.java_websocket.drafts.Draft; | ||
import org.java_websocket.handshake.ServerHandshake; | ||
|
||
/** | ||
* title: JieWebSocket.java | ||
* @author jwzhangjie | ||
* Date: 2014-12-6 下午3:34:22 | ||
* version 1.0 | ||
* {@link http://blog.csdn.net/jwzhangjie} | ||
* Description:与后台通过WebSocket通信的封装 | ||
*/ | ||
public class JieWebSocket extends WebSocketClient { | ||
|
||
public JieWebSocket(URI serverUri, Draft draft) { | ||
super(serverUri, draft); | ||
} | ||
|
||
public JieWebSocket(URI serverUri, Draft protocolDraft, | ||
Map<String, String> httpHeaders, int connectTimeout) { | ||
super(serverUri, protocolDraft, httpHeaders, connectTimeout); | ||
} | ||
|
||
public JieWebSocket(URI serverURI) { | ||
super(serverURI); | ||
} | ||
|
||
@Override | ||
public void onClose(int arg0, String arg1, boolean o) { | ||
|
||
} | ||
|
||
@Override | ||
public void onError(Exception exception) { | ||
exception.printStackTrace(); | ||
} | ||
|
||
/** | ||
* 接收后台发送的信息,格式自己定义 | ||
*/ | ||
@Override | ||
public void onMessage(String msg) { | ||
|
||
} | ||
|
||
@Override | ||
public void onOpen(ServerHandshake server) { | ||
|
||
} | ||
|
||
} |