/** * Sends a request to stream this client all vehicles that have been recently tagged as violations */ public static void recentVehiclesRequest() { if (!isConnected()) { return; } Packet toSend = new Packet(Packet.RecentVehiclesCommand); byte[] bytesToSend = SerializationUtils.packetToBytes(toSend); client.writeMessage(bytesToSend); }
/** * Sends a search request given a key to search to the server if a connection exists. Data sent * back comes streaming to PacketListeners. * * @param searchKey the key to perform a search on */ public static void searchRequest(String searchKey) { if (!isConnected()) { return; } Packet toSend = new Packet(Packet.SearchCommand); toSend.setData(searchKey); byte[] bytesToSend = SerializationUtils.packetToBytes(toSend); client.writeMessage(bytesToSend); }
/** * Sends a server request to store a new platenumber and lotnumber combination with a date pass. * Any vehicles that enter with this combination are ignored by the server until the expiration * date * * @param platenumber the vehicles platenumber * @param lotnumber the vehicles's lotnumber * @param expiration the desired expiration date of the pass */ public static void sendTimePassRequest(String platenumber, String lotnumber, int hours) { Packet toSend = new Packet(Packet.InsertTimePassCommand); Vehicle v = new Vehicle(); v.setLotNumber(lotnumber); v.setPlateNumber(platenumber); v.setTimePassAmount(hours); toSend.setData(v); byte[] bytesToSend = SerializationUtils.packetToBytes(toSend); client.writeMessage(bytesToSend); }
/** * Sends a server request to store a new platenumber and lotnumber combination with a date pass. * Any vehicles that enter with this combination are ignored by the server until the expiration * date * * @param platenumber the vehicles platenumber * @param lotnumber the vehicles's lotnumber * @param expiration the desired expiration date of the pass */ public static void sendDatePassRequest(String platenumber, String lotnumber, Date expiration) { Packet toSend = new Packet(Packet.InsertDatePassCommand); Vehicle v = new Vehicle(); v.setLotNumber(lotnumber); v.setPlateNumber(platenumber); v.setGraceEndDate(expiration); toSend.setData(v); byte[] bytesToSend = SerializationUtils.packetToBytes(toSend); client.writeMessage(bytesToSend); }
// test code public static void test() { // Packet p = new Packet(Packet.ActiveVehiclesCommand); client.writeMessage("test".getBytes()); }