Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
a0d5c1cb
Commit
a0d5c1cb
authored
Jan 23, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump okhttp to 3.5.0
parent
aa7eb67a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
39 deletions
+16
-39
build.gradle
android-ddp/build.gradle
+1
-1
RxWebSocket.java
...src/main/java/chat/rocket/android_ddp/rx/RxWebSocket.java
+9
-20
RxWebSocketCallback.java
.../java/chat/rocket/android_ddp/rx/RxWebSocketCallback.java
+5
-17
dependencies.gradle
dependencies.gradle
+1
-1
No files found.
android-ddp/build.gradle
View file @
a0d5c1cb
...
...
@@ -37,7 +37,7 @@ android {
dependencies
{
compile
project
(
':log-wrapper'
)
compile
rootProject
.
ext
.
supportAnnotations
compile
'com.squareup.okhttp3:okhttp-ws:3.4.1'
compile
rootProject
.
ext
.
okhttp3
compile
rootProject
.
ext
.
rxJava
compile
rootProject
.
ext
.
boltsTask
}
android-ddp/src/main/java/chat/rocket/android_ddp/rx/RxWebSocket.java
View file @
a0d5c1cb
...
...
@@ -4,13 +4,9 @@ import java.io.IOException;
import
chat.rocket.android.log.RCLog
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
okhttp3.ResponseBody
;
import
okhttp3.ws.WebSocket
;
import
okhttp3.ws.WebSocketCall
;
import
okhttp3.ws.WebSocketListener
;
import
okio.Buffer
;
import
okhttp3.WebSocket
;
import
okhttp3.WebSocketListener
;
import
rx.Observable
;
import
rx.Subscriber
;
import
rx.exceptions.OnErrorNotImplementedException
;
...
...
@@ -28,12 +24,11 @@ public class RxWebSocket {
public
ConnectableObservable
<
RxWebSocketCallback
.
Base
>
connect
(
String
url
)
{
final
Request
request
=
new
Request
.
Builder
().
url
(
url
).
build
();
WebSocketCall
call
=
WebSocketCall
.
create
(
httpClient
,
request
);
return
Observable
.
create
(
new
Observable
.
OnSubscribe
<
RxWebSocketCallback
.
Base
>()
{
@Override
public
void
call
(
Subscriber
<?
super
RxWebSocketCallback
.
Base
>
subscriber
)
{
call
.
enqueue
(
new
WebSocketListener
()
{
httpClient
.
newWebSocket
(
request
,
new
WebSocketListener
()
{
@Override
public
void
onOpen
(
WebSocket
webSocket
,
Response
response
)
{
isConnected
=
true
;
...
...
@@ -42,29 +37,23 @@ public class RxWebSocket {
}
@Override
public
void
onFailure
(
IOException
e
,
Response
response
)
{
public
void
onFailure
(
WebSocket
webSocket
,
Throwable
err
,
Response
response
)
{
try
{
isConnected
=
false
;
subscriber
.
onError
(
new
RxWebSocketCallback
.
Failure
(
webSocket
,
e
,
response
));
subscriber
.
onError
(
new
RxWebSocketCallback
.
Failure
(
webSocket
,
e
rr
,
response
));
}
catch
(
OnErrorNotImplementedException
ex
)
{
RCLog
.
w
(
ex
,
"OnErrorNotImplementedException ignored"
);
}
}
@Override
public
void
onMessage
(
ResponseBody
responseBody
)
throws
IOException
{
public
void
onMessage
(
WebSocket
webSocket
,
String
text
)
{
isConnected
=
true
;
subscriber
.
onNext
(
new
RxWebSocketCallback
.
Message
(
webSocket
,
responseBody
));
subscriber
.
onNext
(
new
RxWebSocketCallback
.
Message
(
webSocket
,
text
));
}
@Override
public
void
onPong
(
Buffer
payload
)
{
isConnected
=
true
;
subscriber
.
onNext
(
new
RxWebSocketCallback
.
Pong
(
webSocket
,
payload
));
}
@Override
public
void
onClose
(
int
code
,
String
reason
)
{
public
void
onClosed
(
WebSocket
webSocket
,
int
code
,
String
reason
)
{
isConnected
=
false
;
subscriber
.
onNext
(
new
RxWebSocketCallback
.
Close
(
webSocket
,
code
,
reason
));
subscriber
.
onCompleted
();
...
...
@@ -75,7 +64,7 @@ public class RxWebSocket {
}
public
void
sendText
(
String
message
)
throws
IOException
{
webSocket
.
send
Message
(
RequestBody
.
create
(
WebSocket
.
TEXT
,
message
)
);
webSocket
.
send
(
message
);
}
public
boolean
isConnected
()
{
...
...
android-ddp/src/main/java/chat/rocket/android_ddp/rx/RxWebSocketCallback.java
View file @
a0d5c1cb
...
...
@@ -2,12 +2,9 @@ package chat.rocket.android_ddp.rx;
import
static
android
.
R
.
attr
.
type
;
import
java.io.IOException
;
import
chat.rocket.android.log.RCLog
;
import
okhttp3.Response
;
import
okhttp3.ResponseBody
;
import
okhttp3.ws.WebSocket
;
import
okio.Buffer
;
import
okhttp3.WebSocket
;
public
class
RxWebSocketCallback
{
public
static
abstract
class
Base
{
...
...
@@ -38,8 +35,8 @@ public class RxWebSocketCallback {
public
WebSocket
ws
;
public
Response
response
;
public
Failure
(
WebSocket
websocket
,
IOException
e
,
Response
response
)
{
super
(
e
);
public
Failure
(
WebSocket
websocket
,
Throwable
err
,
Response
response
)
{
super
(
e
rr
);
this
.
ws
=
websocket
;
this
.
response
=
response
;
}
...
...
@@ -57,10 +54,10 @@ public class RxWebSocketCallback {
public
static
class
Message
extends
Base
{
public
String
responseBodyString
;
public
Message
(
WebSocket
websocket
,
ResponseBody
responseBody
)
{
public
Message
(
WebSocket
websocket
,
String
responseBody
)
{
super
(
"Message"
,
websocket
);
try
{
this
.
responseBodyString
=
responseBody
.
string
()
;
this
.
responseBodyString
=
responseBody
;
}
catch
(
Exception
e
)
{
RCLog
.
e
(
e
,
"error in reading response(Message)"
);
}
...
...
@@ -72,15 +69,6 @@ public class RxWebSocketCallback {
}
}
public
static
class
Pong
extends
Base
{
public
Buffer
payload
;
public
Pong
(
WebSocket
websocket
,
Buffer
payload
)
{
super
(
"Pong"
,
websocket
);
this
.
payload
=
payload
;
}
}
public
static
class
Close
extends
Base
{
public
int
code
;
public
String
reason
;
...
...
dependencies.gradle
View file @
a0d5c1cb
...
...
@@ -15,7 +15,7 @@ ext {
rxJava
=
'io.reactivex:rxjava:1.2.2'
boltsTask
=
'com.parse.bolts:bolts-tasks:1.4.0'
okhttp3
=
'com.squareup.okhttp3:okhttp:3.
4.1
'
okhttp3
=
'com.squareup.okhttp3:okhttp:3.
5.0
'
picasso
=
'com.squareup.picasso:picasso:2.5.2'
picasso2Okhttp3Downloader
=
'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
textDrawable
=
'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment