delight-im / android-ddp Goto Github PK
View Code? Open in Web Editor NEW[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
License: Apache License 2.0
[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
License: Apache License 2.0
I have an interesting issue. Android-DDP is going logout and close socket connection when any data come with update.
How can i fix it? Thank you.
Hello! I set up a simple meteor server on localhost
It's fine when accessing via browser:
http://localhost:3000
I tried to connect from my android client and the connection is refused
mMeteor = new Meteor(getApplicationContext(), "ws://localhost:3000/websocket");
12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out: Meteor
12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out: onClose
12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out: code == 2
12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out: reason == failed to connect to localhost/127.0.0.1 (port 3000) after 6000ms: isConnected failed: ECONNREFUSED (Connection refused)
I tried to connect to android-ddp-meteor.meteor.com and it worked just fine, so I think that the problem is with my server, is there any permissions i should there to allow android clients to connect?
I need to know what is the real work for this line
Meteor.setLoggingEnabled(true);
Thanks
Right now, the Meteor
class already has convenience methods for the following two methods from the accounts-password
package:
createUser
login
We should add further methods that wrap the following method calls:
logout
verifyEmail
changePassword
forgotPassword
resetPassword
Hi @mwaclawek
Is known not finished yet?
Serverside.js
mongodb.allow({
remove : function() {
return true;
},
update : function(userId, doc, fields, modifier) {
return true;
},
insert : function() {
return true;
}
});
Java
Map<String, Object> updateQuery = new HashMap<String, Object>();
updateQuery.put("_id", "r87MfSvjMdaD9J8Lh");
Map<String, Object> updateValues = new HashMap<String, Object>();
Map<String, Object> options = new HashMap<String, Object>();
updateValues.put("some-number", 5);
DDP.mMeteor.update("mongodb", updateQuery, updateValues)
LogCat:
09-12 06:25:37.078: I/tikatoy(27287): DDP: Update fail: Access denied. In a restricted collection you can only update documents, not replace them. Use a Mongo update operator, such as '$set'.
Thanks for the answer.
I'm logging in the console some text when these methods get fired, but they are not going off. I am signed in and subscribed correctly. I have also set the callback correctly. None of the callbacks are firing correctly. Could this be an issue with the singleton pattern?
public MeteorHelper(Context context) {
mMeteor = new Meteor(context, context.getString(R.string.url_server));
mMeteor.setCallback(this);
mContext = context;
}
public static synchronized MeteorHelper getInstance(Context context) {
if (mInstance == null) {
mInstance = new MeteorHelper(context);
}
return mInstance;
}
@Override
public void onDataAdded(String collectionName, String documentID, String newValuesJson) {
Log.v(TAG, "(onDataAdded) collection: " + collectionName + " documentId: " + documentID + " payload: " + newValuesJson);
}
@Override
public void onDataChanged(String collectionName, String documentID, String updatedValuesJson, String removedValuesJson) {
Log.v(TAG, "(onDataChanged) collection: " + collectionName + " documentId: " + documentID + " payload: " + updatedValuesJson);
}
@Override
public void onDataRemoved(String collectionName, String documentID) {
Log.v(TAG, "(onDataRemoved) collection: " + collectionName + " documentId: " + documentID);
}
Instead they are just going to my log like so:
06-12 16:19:39.146 6960-6960/com.walintukai.watchdog.debug I/System.out﹕ RECEIVE: {"msg":"added","collection":"assets","id":"cZCMZabRbPmEt3gk5","fields":{"name":"House 1","desc":{"country":"USA","city":"Emeryville","postal":"942828","street":"Christie Ave","year":2004}}}
06-12 16:19:39.146 6960-6960/com.walintukai.watchdog.debug I/System.out﹕ RECEIVE: {"msg":"ready","subs":["fff1d350-5270-490e-87dc-1f6b783e6ab1"]}
Hi guys,
I'm testing on local ws://192.168.2.133:3000/websocket
and everything working fine
but got stuck with real server which is Ubuntu 14 on DigitalOcean via MUP. ws://128.199.207.81:3000/websocket
onDisconnect : failed to connect to /128.199.207.81 (port 3000) after 6000ms: isConnected failed: ECONNREFUSED (Connection refused)
client js version 128.199.207.81
is working fine btw, so any hint would be appreciated.
Thanks
Thanks for your code, in theory this fits in nicely with what I am trying to do.
I saw a subscribe method in documentation that returns a string
String subscriptionId = mMeteor.subscribe("my-subscription");
Since this example is just string and I might want to subscribe to more complicated data structure than a plain string. like a row in MongoDB. How would I go about doing that? would I have to subscribe to each individual column seperately?
Is there a example code for how one may dynamically subscribe to a bigger collection data and update the UI on the fly without too much code? From the current examples in the documentation its not very easy to know if this is possible.
Thanks!
It looks like it's currently not possible to create a subscription using arguments, and you must always subscribe to a publication that has no arguments. Is that correct?
If this is the case, it would be very beneficial to add that functionality. I think it's pretty typical to subscribe to a subset of documents based on some chosen value so that an entire collection is not sent over the wire.
Hi, i came this time with a question
I've done subscribe and publish, and i've done a call method and this work fine, but ¿How to get the data from db? ¿Do I need to use onDataAdded, onDataChanged and onDataRemoved methods?
Thanks.
Map<String, Object> signInValues = new HashMap<String, Object>();
signInValues.put("email", email);
signInValues.put("password", password);
mMeteor.call("/users_booklook/find", signInValues);
why I cant call method with 2 parameter like above in my android .
Hi, I noticed that when a subscription is successful, an onDataAdded
event is fired for each record of the data loaded by the subscription (data existing in the database up to the subscription time). Wouldn't the onDataAdded
event be better fired only when new data is added after the subscription? The data loaded by the subscription can be delivered in the onSuccess
callback of the SubscriberListener
.
Hi,
I'm trying to call Accounts.callLoginMethod method from my Android device. But, I get an error: 404, Method not found.
Is there a possible way to call a method from a different package or is it a feature yet to be implemented?
Thanks, in advance.
What's the diffrerence between Meteor and MeteorSingleton? For example:
If i will initialize variable like this:
Meteor mMeteor = new MeteorSingleton.createInstance(this,"some_web_socket");
Is it right implementation? If not what case will be right?
This must be a very dumb question, but how can i get all the initial collection items after subscribing to it?
I've looked into the onSuccess callback of the SubscribeListener but i didn't have any luck.
Thanks.
Can you please provide examples on how to pass parameters to Meteor.call()
? How exactly can I pass an object like
{ key1: "value1", key2: "value2"}
or multiple objects or a mix of objects and arrays?
Hello, How can I get the json result when I subscribe to a colleciton ?
How does Android-DDP compare to android-ddp-client? Do both libraries have the same features? I am considering making a switch from android-ddp-client to this library, but I want to make sure that its features are on par first.
See: https://github.com/kenyee/android-ddp-client
I know this isn't an "issue", I just couldn't find any other way to contact the developer.
How are you, The result is not a valid json data, it for more than two " "
if (listener instanceof ResultListener) {
mListeners.remove(id);
final String result;
if (data.has(Protocol.Field.RESULT)) {
result = data.get(Protocol.Field.RESULT).toString();
}
}
how can I call collection.find()
on android? meteor.call("/Collection/find")
gives 404 despite that it works on the web client.
When developing with meteor for the client, it implicitly uses a minimongo db on the clientside, which also stores the data in the local storage. Also this enables users to run queries (sort, filter) on those data sets.
I've been saving the data coming in currently to local HashMaps but sorting and filtering data items is really resource intensive and leads to many UI hangs. Is there any solution or suggestion on how to save this data locally and have decent performance for getting specific subsets?
(One could of course always just subscribe to the specific published feed in every activity but there is not persistence when switching)
hey Can you give an android client and server interaction implementation example of add and delete
All Android-DDP examples shows on one activity. How can i use it on different activities. For example i connect my server in first activity and go next activity. How can i carry it. Maybe i can use singleton but i don't know.
How can i implement it?
Thank you.
At Protocol.java:84 you check for Protocol.Field.REASON
where I assume you meant Protocol.Field.ERROR
. This means that if the error has an error
field but not a reason
field, the error
is incorrectly null
.
Would be awesome, if one could get the source code directly via maven.
Currently it is kinda messy to include the source code as a separate module in android studio.
how is it possible to get the items synced localy for an offline-app?
Hi - I'm having a bear of a time understanding how to use your code in my project, since there are no obvious .jar or project/gradle files. Once you download the repo, what are the steps to include the library? I'm using Android Studio.
Thanks!
I have deployed my Server to meteor.com and it's succeed. This is my site http://booklook-coba.meteor.com/. but when I try to connect it with websocket protocol it's failed. This is my protocol "ws://booklook-coba.meteor.com:443/websocket". The connection always lost. I cannot do CRUD into my database even though it's working in my localhost.
Could you tell me more about this? Thank you
How can we get Android subscription data
i am getting error 'WebSockets protocol violation' when i use "MeteorSingleton.getInstance().loginWithEmail"
log stack trace
Meteor
System.out: send
System.out: message == {"msg":"method","id":"cf4114bb-126d-458d-a8f3-70f6c4ae43b8","params":[{"password":"mypassword","user":{"email":"[email protected]"}}],"method":"login"}
System.out: dispatching
WebSocketException (de.tavendo.autobahn.WebSocketException: RSV != 0 and no extension negotiated)
.WebSocketReader: ended
WebSocketConnection: fail connection [code = 4, reason = WebSockets protocol violation
WebSocketReader: quit
WebSocketWriter: ended
System.out: Meteor
System.out: onClose
System.out: code == 4
System.out: reason == WebSockets protocol violation
System.out: MeteorSingleton
System.out: onDisconnect
System.out: code == 4
System.out: reason == WebSockets protocol violation
MainActivity: WebSockets protocol violation
in Meteor.java, disconnect() method, on line 225 mCallback is set to null - therefore, onDisconnect() callback will never be fired. Is that a bug or is onDisconnect() supposed to happen only for non-user initiated disconnect? (sorry if I didn't ask this the right way or in the right place - this is my very first post on GitHub)
To replicate this issue, log in to the same user account with two different devices (one being an Android device using Android-DDP). Configure your logout to use the Meteor.logoutOtherClients() method which will log out all devices for a certain account when one of the devices logs out. Now, log out on your account on the non-Android device. Due to the logout configuration stated above, the logout on the non-Android device will cause the Android device to be logged out. When the Android device gets logged out, its DDP connection is lost and the Android-DDP library gracefully re-establishes the connection. However, the login token is no longer valid and Android-DDP can't automatically log the Android device back in. In this circumstance, the mLoggedInUserId field is not cleared and the Meteor class will still return true when isLoggedIn() is called.
mMeteor.call("/auto", new ResultListener() {
@Override
public void onSuccess(String result) {
Log.e("TAG", "result=========="+result);
}
@Override
public void onError(String error, String reason, String details) {
// TODO Auto-generated method stub
Log.e("TAG", "error=========="+error);
Log.e("TAG", "reason=========="+reason);
Log.e("TAG", "details=========="+details);
}
});
why reason==========Method not found error==========404
Hi!
I've done another example of a todo list hosted here:
http://todoandroidddp.meteor.com/
With login, add tasks, receive it reactively and now working in delete, if you don't mind I can upload into a branch or a pull request to master :)
And I'm thinking about to develop offline feature with Realm (https://realm.io/) for the tasks model as example too.
Hey,
I have an app with 3 activities (Login, List, Detail of item).
I need to be able to completely clean my List activity when I move back to login.
At the moment, I unsubscribe during the onStop() and subscribe during the onStart() but the second time I log in, I receive nothing.
Do you have an idea ?
Thanks (awesome library !)
Hello,
I did copy from jar to libs and I got this error:
09-10 11:01:58.354: I/dalvikvm(2718): Failed resolving Lcom/example/android_ddp/MainActivity; interface 85 'Lim/delight/android/ddp/MeteorCallback;'
And
09-11 02:12:11.758: W/dalvikvm(3326): Link of class 'Lcom/example/androidddp/MainActivity;' failed
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidddp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.androidddp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Hi guys,
I'm using present version of Meteor and deploy with mup
to DigitalOcean
Which all working fine with js client. but I got stuck for native Android (device/emulator x86) somehow.
Here's my code, some other code is just Log
for callback
mMeteor = new Meteor(this, "http://123.456.789.00");
mMeteor.setCallback(this);
When I try to connect, it always throw WebSockets connection lost
Anyone hit this before? I think I just miss something stupid.
uses-permission
is set BTW
ws:://123.456.789.00
is not working either
http://localhost:3000
is not working but this should be emulator issue.
http://192.168.2.133:3000
local IP is no luck too.
even worst, sometime it's not call back e.g. after I try registerAndLogin
or else.
I think I'm doom! Any help would be appreciate.
Thanks
Hello, I looking for login (mail, password) to meteor server with your app. can you help me ?
How to keep a user logged in or log him automatically without saving his password? I noticed that the login request returns a token. Can't this be used?
I see the project is not under Gradle build system.
Can we migrate this to gradle ?
It would help in development of apps that use Android-DDP, if android-ddp-0.0.1-bundle.jar
contained also source files of Android-ddp library. This way one could easily peek how given library class is implemented.
If you prefer to keep sources outside of bundle jar, consider providing separate android-ddp-0.0.1-bundle-src.jar with sources only.
Any reason against publishing the JARs to Sonatype? I realize it's a pain in the ass, but I'd be more than happy to lend a hand getting things setup if you're amenable to the idea.
Hello,
it's possible connect to meteor server with Google or Facebook account ?
tks
Hello! In 2.0 version (jar) when i succesfull login(with loginWithEmail) and subscribe to a collection from the server, i start to get errors like these(but when i just login without subscribe to any collections i haven't errors):
D/onException: com.firebase.tubesock.WebSocketException: IO Error
D/onException: com.firebase.tubesock.WebSocketException: IO Exception
D/onException: com.firebase.tubesock.WebSocketException: IO Error
payload == {"msg":"result","id":"e3f66184-be65-4175-836b-f976680877aa","error":{"error":403,"reason":"You've been logged out by the server. Please log in again.","message":"You've been logged out by the server. Please log in again. [403]","errorType":"Meteor.Error"}}
I log out after each 30 seconds - 1 minute. In older versions of android-ddp.jar i haven't that problems.
The Autobahn library doesn't have support for the wss
protocol so either switch to another library or wait until the feature is added
how to sett up server for this library, I made an android native app with this library and I use meteor for my web service. I dont remove insecure package and autopublish package. so I can Insert, delete and update without subscribe or call the method in client.
but my problem is I can not connect to my localhost. I use genymotion for the android emulator.
Any one can Help me, please,,, Thank you for this amazing library
It's my first time work with Web Socket,,
here is my code https://ideone.com/pXzJW8
What is the reason for making loginWithToken private? Is it design decision or due to security issues?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.