Advertisement
Guest User

Untitled

a guest
Jan 17th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1.  private void setupStreams() throws IOException{
  2.  
  3.           input = new ObjectInputStream(connection.getInputStream());
  4.        }
  5.      
  6.  
  7. private void whileChatting() throws IOException{
  8.          
  9.           do{
  10.              
  11.              try{
  12.  
  13.                  if (connection.isClosed()) break;
  14.                  Object inputData = new Object();
  15.                  inputData = input.readObject();
  16.                  //input.reset();
  17.  
  18.                 Message por = new Message();
  19.                  por = (Message) inputData;
  20.         sendMessage(por);
  21.  
  22.            }catch(ClassNotFoundException classNotFoundException){
  23.                //closeCrap();
  24.              }
  25.              
  26.           }while(true);
  27.        }
  28.        
  29.      
  30.  
  31.        
  32.        private void sendMessage(Poruka message) throws IOException{
  33.            int var = Server.kontrolni2;  // variable which checks to which stream to send message  
  34.            output = new ObjectOutputStream(Server.ClientSockets.get(var - 1).getOutputStream());
  35.               try{
  36.                  output.writeObject(message);
  37.                  output.flush();
  38.               }catch(IOException ioException){
  39.               }
  40.            }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement