Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JetEvent deserialization under AMF3 protocol on flash client. messageBuffer is null. #33

Closed
griand opened this issue Dec 27, 2012 · 2 comments

Comments

@griand
Copy link

griand commented Dec 27, 2012

Hello, menacher.
Thank you for your jet server.

I have next trouble. If I use MessageBufferProtocol on Jet Server and on flash client then all fine, I can send and receive message in both ways.

But if I try use the AMF3 protocol on flash client:
in SessionFactory.as:
public function createAndConnectSession():Session {
var session:Session = createSession();
connectSession(session, new AMF3Protocol(), new LoginInOutCodecs());
return session;
}

and on jet server in ZombieSpringConfig.java:
@Autowired
@qualifier("amf3Protocol")
private Protocol messageBufferProtocol;

in debug mode I get next exception on flash client on incoming message in Main.as:
private function traceData(event:Event):void{
var jetEvent:JetEvent = event as JetEvent;
var messageBuffer:MessageBuffer = jetEvent.getSource() as MessageBuffer;
var buffer:ByteArray = messageBuffer.getBuffer();
trace("Remaining Human Population: " + buffer.readInt());

[Fault] exception, information=TypeError: Error #1009: messageBuffer is null here.
jetEventType = 28 [0x1c], source = Object ( @ 4e92fb9 ), timestamp = 1356590891591 [0x13bdb1e4247] , but messageBuffer is null after jetEvent.getSource() as MessageBuffer operation, and I not can read received buffer.

How to solve this trouble?

@menacher
Copy link
Owner

Hi,
Thanks of taking interest in jetserver.

Definitely there seems to be an initialization bug. In the AMF3Protocol class, I do not see the serializer and deserializer being initialized. They are null. There maybe other issues also. I will test this out and let you know.

@menacher
Copy link
Owner

The code you have pasted will not work as is. The reason is that, for the Zombie game, only integers are passed between client and server, to select defender/eat brains commad etc.
General usecase for the AMF3 protocol is when you need to pass a whole object between client and server-> Take a look at AMF3ProtocolTest class. It shows how a full object of type PlayerStats is encoded and decoded. You need to have similar class in your flash client and java server, only then you can pass them in between.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants