de.tavendo.autobahn.WebSocketException Java Examples
The following examples show how to use
de.tavendo.autobahn.WebSocketException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PullService.java From ALLGO with Apache License 2.0 | 5 votes |
private void pullWebSocket(){ // TODO 使用WebSocket实时推送 SharedPreferences sharedPref = this.getSharedPreferences("appdata",Context.MODE_PRIVATE); List<BasicNameValuePair> headers = new ArrayList<BasicNameValuePair>(); headers.add(new BasicNameValuePair("Cookie","JSESSIONID="+sharedPref.getString("SessionId", ""))); /*SharedPreferences sharedPref1 = this.getSharedPreferences("userdata",Context.MODE_PRIVATE); headers.add(new BasicNameValuePair("uid",sharedPref1.getInt("uid", -1)+""));*/ try { wsc.connect("ws"+declare.getHost_url().substring(4)+"pull.ws", null, new WebSocketConnectionHandler(){ @Override public void onClose(int code, String reason) { Log.i(TAG, "onClose reason="+reason); } @Override public void onOpen() { Log.i(TAG, "后台推送已连接"); } //接收文本消息 @Override public void onTextMessage(String payload) { readingParse(payload); } }, new WebSocketOptions(), headers); } catch (WebSocketException e) { e.printStackTrace(); } }
Example #2
Source File: FlistWebSocketConnection.java From AndFChat with GNU General Public License v3.0 | 5 votes |
public void connect() { try { WebSocketOptions options = new WebSocketOptions(); options.setMaxFramePayloadSize(256000); application.getConnection().connect(sessionData.getHost(), handler, options); eventManager.fire(ConnectionEventListener.ConnectionEventType.CONNECTED); } catch (WebSocketException e) { e.printStackTrace(); Ln.e("Exception while connecting"); } }