Results 1 to 2 of 2
  1. #1
    megabyte is offline Member
    Join Date
    Jan 2011
    Location
    Moscow
    Posts
    5
    Rep Power
    0

    Default Serialization and event

    Hello.

    I write a chat-server which sends a serialized objects to clients with a full message information (text, nickname, date etc.). And I try to make a client which should get this objects and unserialize it:

    PHP Code:
    ObjectInputStream in = new ObjectInputStream(sock.getInputStream());
    					
    while (true)
    {
    	ChatMessage inMsg = (ChatMessage) in.readObject();
    
    	[...other code...]
    }
    I want to run "other code" only after readObject get a new object via network. Is it possible?

    JMS is a very complex thing for this, because it can't work with a Socket object directly. RabbitMQ requires to run an own server, which is also not good for standalone application.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    I want to run "other code" only after readObject get a new object via network. Is it possible?
    Yes, in.readObject(); is a blocking operation, so it sits there waiting until an object comes in. The same is true for other Socket operations, like readLine();

Similar Threads

  1. Serialization
    By twiggy62 in forum New To Java
    Replies: 2
    Last Post: 02-12-2010, 04:45 AM
  2. Serialization
    By thayalan in forum Advanced Java
    Replies: 4
    Last Post: 08-03-2009, 10:22 PM
  3. checking for an event during an event
    By infinity in forum AWT / Swing
    Replies: 22
    Last Post: 04-09-2009, 01:08 AM
  4. about serialization
    By bishnu in forum New To Java
    Replies: 0
    Last Post: 12-19-2008, 09:13 AM
  5. Replies: 0
    Last Post: 04-04-2008, 02:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •