Skip to content

how to use flash client to send message to this java game sever? and how to config the server side ?

menacher edited this page May 16, 2012 · 6 revisions

A flash client, coded in action script jetclient-as3 is available for JetServer.
Flash games can now use this client for connecting to JetServer. MessageBuffer protocol and an AMF3 Protocol are now implemented.
The client is a work in progress. Life cycle events like close, disconnect etc are not handled yet. If you are an AS3 kick-a** expert, do contribute!

##Session Creation The first step for the client is to create a session and connect it to remote Jetserver. For this, it uses a LoginHelper class and the SessionFactory. Example is available at [Main.as] (https://github.com/menacher/java-game-server/blob/master/jetclient-as3/src/main/flex/org/menacheri/Main.as)

Connecting to jetserver takes about 3 lines.

	var loginHelper:LoginHelper = new LoginHelper("user", "pass", "Zombie_ROOM_1_REF_KEY_1", "localhost", 18090);	
	var sessionFactory:SessionFactory = new SessionFactory(loginHelper);
	var session:Session = sessionFactory.createAndConnectSession();

To receive data from remote jetserver just add the following event handler to the session.

	session.addEventListener(Events.SESSION_MESSAGE_EVENT, yourEventListenerFunction);

To send data to remote jetserver use the following method.

	session.sendToServer(jetEvent);

The jet event can be created using Events class, as shown below.
var jetEvent:JetEvent = Events.event(Events.NETWORK_MESSAGE, somemessage);