我有一个用Java运行的简单的Google Protocol Buffers服务器,我的朋友需要从他的actionscript 3应用程序访问它。我们发现从* .proto生成类很容易:
protoc --plugin=protoc-gen-as3=protoc-gen-as3.bat --as3_oututput my.proto
但我们对实际配置(设置服务器地址和端口),获取通信通道以及实际调用* .proto中定义的服务非常傻。
在Java中,在DuplexTcpClientBootstrap
的帮助下很容易,但是动作脚本是什么?
我尝试使用谷歌搜索,但我能找到的所有内容只与从*.proto
生成类有关,没有调用实际方法/函数的示例。
TIA,我会感激任何链接或示例!
答案 0 :(得分:-1)
使用“pafau k”我们有Java服务器 - 它使用protobuf - 但它写入套接字。 我认为我们有一些误解,因为flex可能在“http”协议上工作 - 我是对的吗?
var callService:CallcenterService = new CallcenterService();
var simpleWebRPC:SimpleWebRPC = new SimpleWebRPC("0.0.0.0:1234/");
callService.sendFunction = xmlsock.send;
callService.getDefaults(new EmptyMessage(), function(result:*):void {
var response:Defaults = result as Defaults;
if (response){
trace("RPC call succeeded:", response);
}
else{
trace("RPC call failed:", ErrorEvent(result).text);
}
});
callService是从proto
生成的message EmptyMessage {}
message Defaults {
required string xmlContents = 1;
}
service CallcenterService {
rpc getDefaults (EmptyMessage) returns (Defaults);
}
这是来自java服务器的错误:
com.googlecode.protobuf.pro.duplex.handler.ServerConnectRequestHandler exceptionCaught
WARNING: Exception caught during RPC connection handshake.
com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.
at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:78)
at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:498)
at com.google.protobuf.GeneratedMessage$Builder.parseUnknownField(GeneratedMessage.java:438)
at com.googlecode.protobuf.pro.duplex.wire.DuplexProtocol$WirePayload$Builder.mergeFrom(DuplexProtocol.java:2565)
at com.googlecode.protobuf.pro.duplex.wire.DuplexProtocol$WirePayload$Builder.mergeFrom(DuplexProtocol.java:2450)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:300)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:238)
at com.google.protobuf.AbstractMessageLite$Builder.mergeFrom(AbstractMessageLite.java:202)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:738)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:238)
at org.jboss.netty.handler.codec.protobuf.ProtobufDecoder.decode(ProtobufDecoder.java:101)
at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:72)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:317)
at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299)
at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:216)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)