I just finished my application in NodeJs using feathersjs. Now I write app on android to communicate with my services by node side. How can I communicate with node service like find/get/create/update via android socket?
Below is my snippet code:
try {
mSocket = IO.socket("http://10.0.130.32:3030");
} catch (URISyntaxException e) {
e.printStackTrace();
}
mSocket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
// socket.emit("foo", "hi");
// socket.disconnect();
}
}).on("config", new Emitter.Listener() {
/*
* Android joins to a room after receiving socket's id from another user
*/
@Override
public void call(Object... args) {
try {
JSONObject object = new JSONObject(args[0].toString());
mSocket.emit("join", object.get("socket"));
id = object.getString("socket");
} catch (JSONException e) {
e.printStackTrace();
}
}
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {}
});
mSocket.connect();
I know that you can use: mSocket.emit("join", "some data"); but I would like call a REST Api for example: http://10.0.130.32:3030/getID in Android via socket.
How can I do that?
via SeaDog
No comments:
Post a Comment