0

First of all I would like to thank all of the great people answering all kinds of questions on this awesome coding-website.

Now to my question:

I just started working with Google App Engine, because I want to use it for a java desktop application I made. The swing application is sending serialized objects from one client to another using sockets. This solution is pretty sloppy and it causes latency problems in some cases. I searched the web for possible server solutions and ended up with Google App Engine.

So, my question is basically: How do I send serialized objects from my swing application to the app engine application server, and vice versa? I have absolutely no idea if it is possible, although I read it can be done by faking the server into thinking I'm a user of the web application, and sending those objects via javascript to the server. Now, I don't know much about javascript, and would like to keep it on the java site, if possible.

I would appreciate any kind of code examples or ideas.

  • are you developing something like peer2peer application or client-server application using Java? – JProgrammer Jul 19 '12 at 20:20
  • I'm developing a client-server application. – Wreck5tep Jul 19 '12 at 20:53
  • Then you will not need Google App Engine for that. Google app engine is for web based application such as servlets etc. In your case, for desktop application (I will call your application as network application) Good way to send data between two network application is using XML. – JProgrammer Jul 19 '12 at 21:08
  • Yeah, I know that, but I need some kind of java webhost which is free. I also really like the idea of the storage possibilities. I could also build a webapp which could show additional informations about the clients connected to the server and so on. – Wreck5tep Jul 19 '12 at 21:12
  • This is from Google app engine documentation. 'The environment includes the Java SE Runtime Environment (JRE) 6 platform and libraries. The restrictions of the sandbox environment are implemented in the JVM. An app can use any JVM bytecode or library feature, as long as it does not exceed the sandbox restrictions. For instance, bytecode that attempts to open a socket or write to a file will throw a runtime exception'. So you can not deploy your application on Google app engine. And I feel that, it is same for any other hosting providers. It is for security reasons. – JProgrammer Jul 19 '12 at 21:53
  • Well, thank you for your answers. Do you have any suggestions on which technologies I could use for my project? It's basically many java clients. I would like to broadcast a certain event to every online client. That's why I was looking for a server which could do just that... – Wreck5tep Jul 19 '12 at 22:00

2 Answers2

0

You can not do broadcast using TCP socket. For that you have to use UDP socket communication.

If you really want to use web hosting for maintaining your server, you can do following things

1) Implement server using Java Servlet. You can host Java servlet on Google app engine.

2) In the client program, use HTTP instead of TCP socket to communicate with server.

3) You can implement virtual broadcast as follows

3.1) In Java client program, start a seperate thread as soon as your program is started

3.2) In that thread, keep pinging Servlet using HTTP request and read response. Using this logic, you can stimulate broadcast.

3.3) you might need to write Separate Servlet to handle this broadcast.

These links will be helpful

How to send HTTP request in java?

http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/

Community
  • 1
  • 1
JProgrammer
  • 1,125
  • 1
  • 10
  • 25
0

Google App Engine has tool that may help called Remote API: https://developers.google.com/appengine/docs/java/tools/remoteapi

That should cover the server API for you. As for serialization, you can do many things: JSON, XML, etc. Personally I prefer JSON, and using Jackson. google-gson is another library you may want to use instead.