Comments (15)
Coincidentally, very soon! I am in the process of refactoring the socket.io client to add that feature, as well as many others. Check out the "wip" branch.
Should be released this weekend.
from androidasync.
Cool.. Thanks alot.
from androidasync.
Fixed in the master branch. Will push to Maven soon.
Requiring an ack:
SocketIOClient client = SocketIOClient.connect(AsyncHttpClient.getDefaultInstance(), "http://koush.clockworkmod.com:8080/", null).get();
client.emit("hello", new Acknowledge() {
@Override
public void acknowledge(JSONArray arguments) {
}
});
Sending an ack:
SocketIOClient client = SocketIOClient.connect(AsyncHttpClient.getDefaultInstance(), "http://koush.clockworkmod.com:8080/", null).get();
client.setStringCallback(new StringCallback() {
@Override
public void onString(String string, Acknowledge acknowledge) {
assertNotNull(acknowledge);
acknowledge.acknowledge(new JSONArray().put(string));
}
});
from androidasync.
Are you sure acknowledges pass correct arguments ?
In my case acknowledge gets invoked but the server doesn't receive acknowledge arguments (it says it's undefined)
from androidasync.
Let me double check. I'm fairly certain it does, as I have tests unit tests around it.
from androidasync.
Hi, I have worked with the acknowledge call back.It does the job well as intented..
from androidasync.
@g00fy- if you could let me know which socket.io server and version you are on, i can take a look.
from androidasync.
I am using socket.io
v9.11 (I have also tries 9.16), the server address is pxl.pl:8000
this is the server code :
socket.on('ping', function(ping){
var ack = function(data){
socket.emit('ack',data);
}
socket.emit('pong','pong', ack);
});
on the client - browser this code works:
socket = io.connect()
c {socket: d, name: "", flags: Object, json: d, ackPackets: 0…}
// XHR finished loading: "http://pxl.pl:8000/socket.io/1/?t=1373874186168". socket.io.min.js:2
socket.on('ack',function(x){console.log("ack",x)})
// c {socket: d, name: "", flags: Object, json: d, ackPackets: 0…}
socket.emit('ping');
// c {socket: d, name: "", flags: Object, json: d, ackPackets: 0…}
socket.on('pong',function(pong,ack){ack('client');})
// c {socket: d, name: "", flags: Object, json: d, ackPackets: 0…}
socket.emit('ping');
// c {socket: d, name: "", flags: Object, json: d, ackPackets: 0…}
ack client
from androidasync.
@g00fy- Thanks, will take a look with that test code.
from androidasync.
@koush any news about this issue? I was using 1.1.4 jar. Maybe the format of the websocket message is invalid ?
from androidasync.
Haven't had a chance to look at this yet, I'll be free this weekend I think
from androidasync.
@g00fy- This should be fixed with:
from androidasync.
Please verify so I can close this issue.
from androidasync.
@koush Works! Thanks!
from androidasync.
I have the same issue,
on the server,if I use socket to emit a command , the acknowledge on client is ok , if I use io.sockets to emit a command, the acknowledge on the client is null
server code:
io.sockets.emit(COMMAND_NAME,emitData,function(d){
console.log('callback from client',d);
});
does not work;
socket.emit('command',{"commandStr":"testhenry"},function(d){
console.log(d);
});
works well
client.on("command", new EventCallback() {
@OverRide
public void onEvent(JSONArray arguments, Acknowledge acknowledge) {
Log.i("command","args: "+ arguments.toString());
try {
if(acknowledge != null) acknowledge.acknowledge(new JSONArray().put("test"));//?does not work
msgIntent.putExtra("msg", arguments.getJSONObject(0).getString("commandStr"));
sendBroadcast(msgIntent);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//context.sendBroadcast(arg0);
}
});
the acknowledge is null.
from androidasync.
Related Issues (20)
- websocket server will close when receive data in version 3.0.8
- websocket server will block after send big text string HOT 1
- java.net.ConnectException: failed to connect to
- version:3.1.0,AsyncHttpServer not work
- Using AyncDataGram Server to Broadcast data to all clients connected to It
- AsyncNetworkSocket allocator give currentAlloc 0 most of time because of it unable to read and write using AsyncSocket
- 设置返回值code无效,啥情况 HOT 1
- mDataHandler failed to consume data HOT 1
- Callback is not received when network is poor and connection is terminated from other End HOT 1
- Version in the readme is old
- exception when connect to server HOT 1
- Running websocket server in background
- Can not add Http Header HOT 2
- Following the basic websocket example code, but HOT 1
- client got Connection reset by peer error when try to send binary message HOT 2
- Does the library use some Tracking link? HOT 2
- Finf
- How to do server support Multi-Threading and High concurrency HOT 2
- NullPointerException in HybiParser ( version 3.1.0 )
- mp3 with mediaplayer of android can not play over http
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 androidasync.