Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Java Server for Actionscript 3.0--Starting Help

TuxBobbleTuxBobble Posts: 6Member
I'm working on a game in Flash/AS3. The idea is to have a multiplayer game running using Flash clients, and a Java server for synchronization.

As of right now I'm a LONG way away from accomplishing that goal. I've used Java before, but not in a while so I'm rusty. And at that, I hadn't ever really done java.net stuff before, but I'm trying to brush up and learn a few things in the process.

So, I found this Java server/client pair from http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

I tried trimming the server down (I don't want any Knock Knock jokes right now lol) to communicate with AS3 using AS3's XMLSockets class. As of right now, I'm trying to figure out which side is causing the problem, so I had to choose between Java and AS forums for this post. I'm trying here first since I'm a bit more familiar with AS3 so I want to check that I'm doing things right on the Java side first.

[code]try{
//auto-flushing PrintWriter on client's outputstream
PrintWriter out = new PrintWriter(clntsocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clntsocket.getInputStream()));
String inputLine;
inputLine = in.readLine();
if(inputLine != null){
System.out.println(inputLine);
out.println("Received OK!");
}
}
catch(Exception e){
System.out.println("WTF");
}[/code]

I want to verify that I'm doing things right. The PrintWriter auto-flushes the stream, as far as I can tell. BufferedReader works fine, and the console print of inputLine works, so it's not missing the conditional statement or anything like that. But I can't seem to figure out how to transmit (or perhaps simply receive) the PrintWriter's flushed println. If anyone has any tips about what I'm doing here please let me know. The whole try-catch section is in a while() to keep it looping--not sure if that affects anything the way java.net transmits.


UPDATE: I found the issue. Apparently on the Java side you need to terminate with a at the end of the transmission. That seems to allow for recognition of the transmission.

Any tips on XML format manipulation on the server side? Or should I just pass the "meat" of the XML, and receive it back into the same location to upadte the XML?
Sign In or Register to comment.