• Post Reply Bookmark Topic Watch Topic
  • New Topic

urgent help required  RSS feed

 
Chris Lavery
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody,
im currently doing an assignment for next week in which i have to create the server side of a client/server message board. So far i have created a class for storing info on topics for the messageboard, a class to maintain a list of recent updates, then i have implemented a server. My problem comes now with adding methods such as that for sending out a list of topics, getting a block of messages etc. i have never done server side methods and they just seem so different to methods i started off in java doing. i know this is a big ask, but if anyone would be willing to provide long term help (well, til next week wen the deadline is ) could they email me at kuruptcube@hotmail.com and il send u the full problem and my code etc.
Thanks in advance
Chris
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The actual methods inside a server are not that different from normal ones. If you had two objects with no client-server structure you could call like this:

ObjectA ---> ObjectB

With client and remote server you have to add some stuff like:

ObjectA ---> ClientProtocol ---(network)---> ServerProtocol ---> ObjectB

Try to keep ObjectA and ObjectB as much like they were before as you can. That means ClientProtocol might have a method getTopicList() that opens a socket and sends "getTopicList" as a string to the server. The ServerProtocol would receive "getTopicList" and call ObjectB.getTopicList(). Going back the server protocol puts the result back on the network, and the client protocol gets the result off the network and returns it to ObjectA.

This putting stuff on the network and getting it back off involves marshalling and unmarshalling, which just means converting objects into bytes you can send over sockets or whatever network classes you use and converting bytes back into objects. You can convert very simple requests and responses to strings by hand. For more complex messages you might look into serializing objects or XML.

A Java feature called RMI - Remote Method Invocation - does almost all of this tricky stuff for you. The learning curve for RMI might not fit in the next week, but if your messages are very tricky it might be even easier than building something by hand. Google for "Java RMI tutorial" and see how it looks.

Any of that help? How is your server built so far? Sockets or something fancier?
 
Adam Richards
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tip: Try to use more specific subject lines. The more meaningful your subject, the more meaningful your replies.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!