Closed wsky closed 11 years ago
upperlayer rpc control
flag 0-65533 |
---|
header |
payload |
pair<flag, handler>
top-remoting will do this
https://github.com/wsky/top-link/compare/0b269d3f13...92f076a34e
remoting implementation v0.1
low-level implementation to support application extension.
Server Bind
URI uri = new URI("ws://localhost:9001/link");
WebSocketServerChannel serverChannel = new WebSocketServerChannel(uri.getHost(), uri.getPort());
Endpoint server = new Endpoint();
server.setChannelHandler(new RemotingServerChannelHandler() {
@Override
public byte[] onRequest(ByteBuffer buffer) {
return "ok".getBytes();
}
});
server.bind(serverChannel);
Call
ByteBuffer resultBuffer = RemotingService.connect(uri).call("hi".getBytes(), 0, 2);
assertEquals("ok", new String(new byte[] { resultBuffer.get(), resultBuffer.get() }));
swaggersocket protocol impl
https://github.com/wordnik/swaggersocket/tree/master/protocol
use identity for timing
Use heartbeat
the following protocol, identity is flag, but not extendable
{
"handshake" : {
"protocolVersion" : "1.0",
"protocolName" : "SwaggerSocket",
"dataFormat" : "JSON",
"identity" : 0,
"path" : "/any_url",
"method" : "GET",
"headers" : [
{
"name" : "name",
"value" : "value"
}
],
"queryStrings" : [
{
"name" : "name",
"value" : "value"
}
]
},
"requests" : [
{
"uuid" : 0,
"method" : "POST",
"path" : "/any_url/",
"headers" : [
{
"name" : "Content-Type",
"value" : "test/plain"
}
],
"queryStrings" : [
{
"name" : "foo2",
"value" : "bar2"
}
],
"messageBody" : "Swagger Socket Protocol is cool"
}
]
}
Very Usefull Case! Thanks!
@natame spread and use :)
Netty issue#1112 https://github.com/netty/netty/issues/1112
Add support for full WebSocket Request/Response message handling
top-link.remoting done
https://github.com/wsky/top-link/commit/8e73ba838a68e709588720f6d0e244ef3e0013a7
At this layer to achieve this function is not suitable for
upper layer app can use custom channelhandler to imple it for timing