Comments (3)
In final version of rails 5 they did change few things to make more consistient in communication. I have fixed this issue with this pull request: #6
from actioncable-client-java.
Merge #6 and tagged as 0.1.1
from actioncable-client-java.
thanks for the replies
but i solved it by updating the okhttp library and options.reconnection = false;
if reconnection
is false
then it doesn't disconnects so i did this for reconnecting
public void connect() {
task = new TimerTask() {
@Override
public void run() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("channel", "ConversationsChannel");
if (isConnected)
subscription.perform("subscribe", jsonObject);
}};
timer = new Timer();
IntentFilter filter = new IntentFilter("com.pantera.thegrid.SOCKET_OPERATION");
LocalBroadcastManager.getInstance(context).registerReceiver(receiver, filter);
String wsuri = LINK + "email=" + Constants.EMAIL
+ "&sessionToken=" + Constants.SESSION_TOKEN
+ "&client=" + Constants.CLIENT;
Log.v("connecting to", wsuri);
URI uri = null;
try {
uri = new URI(wsuri);
} catch (URISyntaxException e) {
e.printStackTrace();
}
Consumer.Options options = new Consumer.Options();
options.reconnection = false;
options.reconnectionMaxAttempts = 5;
options.reconnectionDelayMax = 1000 * 10;
consumer = ActionCable.createConsumer(uri, options);
Channel appearanceChannel = new Channel("ConversationsChannel");
subscription = consumer.getSubscriptions().create(appearanceChannel);
subscription
.onConnected(new Subscription.ConnectedCallback() {
@Override
public void call() {
Log.v("onConnected", "subscription has been successfully completed");
isConnected = true;
}
})
.onRejected(new Subscription.RejectedCallback() {
@Override
public void call() {
Log.v("onRejected", "subscription is rejected by the server");
isConnected = false;
}
})
.onReceived(new Subscription.ReceivedCallback() {
@Override
public void call(final JsonElement data) {
Log.v("onReceived", "subscription receives data from the server " + data.toString());
}
})
.onDisconnected(new Subscription.DisconnectedCallback() {
@Override
public void call() {
isConnected = false;
// disconnect();
// connect();
}
})
.onFailed(new Subscription.FailedCallback() {
@Override
public void call(final ActionCableException e) {
Log.e("onFailed", "subscription encounters any error " + e.toString());
isConnected = false;
// disconnect();
// connect();
}
});
consumer.connect();
timer.schedule(task, 2000, 2000);
}
from actioncable-client-java.
Related Issues (20)
- Upgrade of okhttp-ws from 2.5.0 to 2.7.5
- Upgrade of okhttp-ws from 2.X to 3.X HOT 2
- problem when trying to make a toast HOT 3
- Build #39 was broken. HOT 3
- java.lang.NoClassDefFoundError: com.hosopy.actioncable.Connection$4 HOT 3
- How can i set client origin. HOT 4
- Remove action property from command data HOT 2
- Actioncable not working with build release. HOT 7
- Readme change request: Origin header HOT 1
- problem when sending data HOT 1
- W/System.err: com.hosopy.actioncable.ActionCableException: java.io.EOFException HOT 2
- Connection to action cable is failed every time. Guide me where i am wrong HOT 1
- Crash on Android HOT 2
- New Maintainer HOT 4
- consumer.disconnect() is not unsubscribing the subscriptions HOT 5
- How to use in the background? HOT 2
- Why support for IOS? HOT 2
- It will create multiple connection with server when switch wifi
- Fix proguard rule in readme, please HOT 3
- Failed to resolved "this dependency" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actioncable-client-java.