Comments (5)
Maybe you only tried the release 0.2.RC1 - the unsubscribeAndDisconnect() method was implemented later, I was just referring to the corresponding git commit.
But you can try the 0.2.RC2 release, which I published right now: https://github.com/hosopy/actioncable-client-java/releases/tag/0.2.RC2
If there is any isses, I will reopen this ticket again - right now it works pretty fine for my company in production.
from actioncable-client-java.
I've added a method called consumer.unsubscribeAndDisconnect()
, would be fine if someone could give feedback on this, see commit 69c519e
After using this method, I also don't get the invalid/unrequested callback calls again.
Unfortunately my test is broken, I don't know why right now...
from actioncable-client-java.
He agregado un método llamado
consumer.unsubscribeAndDisconnect()
, estaría bien si alguien pudiera dar su opinión sobre esto, vea cometer 69c519eDespués de usar este método, tampoco recibo nuevamente las llamadas de devolución de llamada no válidas / no solicitadas.
Desafortunadamente mi examen está roto, no sé por qué en este momento ...
I tried this change and it did not work, update to version 0.2 and it does not recognize the method. Thank you.
from actioncable-client-java.
It is now, I updated to version 0.2.RC2. A question this configuration is correct?
public static void connectToActionCable() throws URISyntaxException {
String domain = "192.168.0.103:3000";
// 1. Setup
URI uri = null;
try {
uri = new URI("ws://".concat(domain).concat("/cable"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
Consumer.Options options = new Consumer.Options();
options.reconnection = true;
options.headers = new ArrayMap<>();
options.headers.put("Origin", "http://".concat(domain));
options.headers.put("Content-Type", "application/json");
final Consumer consumer = ActionCable.createConsumer(uri, options);
if (consumer.isConnected()){
// 2. Create subscription
Channel appearanceChannel = new Channel("BookChannel");
final BookSubscription subscription = consumer.getSubscriptions().create(appearanceChannel, BookSubscription.class);
Log.d("cableDebug", ""+subscription.getIdentifier().toString());
subscription
.onConnected(new Subscription.ConnectedCallback() {
@Override
public void call() {
Log.d("cableDebug", "onConnected");
subscription.join();
}
})
.onRejected(new Subscription.RejectedCallback() {
@Override
public void call() {
Log.d("cableDebug", "onRejected");
// Called when the subscription is rejected by the server
}
})
.onReceived(new Subscription.ReceivedCallback() {
@Override
public void call(JsonElement data) {
Gson gson = new Gson();
Log.d(TAG, "Datos recibidos: " + data);
//notification();
}
})
.onDisconnected(new Subscription.DisconnectedCallback() {
@Override
public void call() {
Log.d("cableDebug", "onDisconnected");
// Called when the subscription has been closed
consumer.unsubscribeAndDisconnect();
}
}).onFailed(new Subscription.FailedCallback() {
@Override
public void call(ActionCableException e) {
Log.d("cableDebug", "onFailed: " + e.getMessage());
e.printStackTrace();
// Called when the subscription encounters any error
consumer.unsubscribeAndDisconnect();
}
});
// 3. Establish connection
consumer.connect();
}else{
consumer.connect();
}
from actioncable-client-java.
Hi, sorry for the inconvenience. Will you have an example of this code in production? I am using evernote job Android for background work and every time this code is executed I create a new subscription.
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
- 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.