// CSC 442F - Software Engineering
// Software:    Calendar Client
// Component:   GetRooms class
// Description: Get room list

import java.io.*;
import java.util.*;
import java.awt.*;

public class GetRooms
{
  private StringTokenizer tokens;
  private String rbuffer;
  private String nbuffer;
 
  public GetRooms(ClientSocket clientsocket, Choice roomchoice)
  {
    try 
    {
      clientsocket.Write("listallrooms,");
      String buf = new String (clientsocket.Read()); 

      if (buf.regionMatches(false, 0 , "192", 0,  3))
      {
        tokens = new StringTokenizer (buf, ",");
        tokens.nextToken(); //throw away response number
        while (true)
        { 
          String rbuffer = new String (tokens.nextToken()); 
          if (rbuffer.regionMatches(false, 0 , "END", 0,  3))
 	          break;	            

          String nbuffer = new String (tokens.nextToken());
          roomchoice.add (rbuffer + " holds " + nbuffer + " people"); 
        }
      }     
    }
      
    catch (IOException io)
    {
    }
  }
} 
