Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
janusle committed May 6, 2012
1 parent 5aeb472 commit 0816fa4
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions client/MultiClient.java
Expand Up @@ -47,7 +47,7 @@ private void unsubscribe() throws Exception{
out.close();
in.close();
csocket.close();

System.out.println("Time unsubscribed");

}else{
Expand Down Expand Up @@ -94,17 +94,18 @@ class SocketProcess implements Runnable{


private void getTime() throws Exception{


Socket s = ss.accept();

Socket s = ss.accept();

ObjectInputStream in = new ObjectInputStream( s.getInputStream() );
timeinfo = (TimeInfo)in.readObject();
System.out.println( timeinfo.time );

in.close();
s.close();


ObjectInputStream in = new ObjectInputStream( s.getInputStream() );
timeinfo = (TimeInfo)in.readObject();
System.out.println( timeinfo.time );

in.close();
s.close();


}

public void cast(){
Expand Down Expand Up @@ -134,7 +135,8 @@ public void cast(){
out.writeObject( timeinfo );
out.close();
s.close();
System.out.println("Time is sent to client " + i + " " + ip.getHostAddress() + ":" + port + "\n");
System.out.println("Time is sent to client " + i + " " + ip.getHostAddress()
+ ":" + port + "\n");
return;
}
catch(Exception e)
Expand Down Expand Up @@ -208,8 +210,11 @@ public void run(){
if( ( cons = System.console() ) != null &&
( cmd = cons.readLine() ) != null ){

if ( cmd.equals("ussb") )
if ( cmd.equals("ussb") ){
this.unsubscribe();
System.out.println("Client is exiting...");
System.exit(0);
}
else{

System.out.println("Unknown cmd");
Expand Down

0 comments on commit 0816fa4

Please sign in to comment.