001    /**
002     * Copyright 2007 Mike Kroutikov.
003     *
004     * This program is free software; you can redistribute it and/or modify
005     *   it under the terms of the Lesser GNU General Public License as 
006     *   published by the Free Software Foundation; either version 3 of
007     *   the License, or (at your option) any later version.
008     *
009     *   This program is distributed in the hope that it will be useful,
010     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
011     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012     *   Lesser GNU General Public License for more details.
013     *
014     *   You should have received a copy of the Lesser GNU General Public License
015     *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
016     */
017    
018    package org.otfeed.protocol.request;
019    
020    
021    import org.otfeed.event.ICompletionDelegate;
022    import org.otfeed.event.OTError;
023    import org.otfeed.protocol.CommandEnum;
024    
025    import java.nio.ByteBuffer;
026    
027    /**
028     * Represents a request to cancel an existing tick, book, option chain, or
029     * historical data request.
030     */
031    public final class CancelRequest extends AbstractSessionRequest {
032    
033            private final int targetRequestId;
034    
035            public CancelRequest(CommandEnum cancelCommand,
036                                    int requestId, 
037                                    int targetRequestId,
038                                    ICompletionDelegate completionDelegate) {
039                    super(cancelCommand, requestId, completionDelegate);
040                    this.targetRequestId = targetRequestId;
041            }
042    
043            @Override
044            public void writeRequest(ByteBuffer out) {
045                    super.writeRequest(out);
046                    out.putInt(targetRequestId);
047            }
048    
049            public void handleError(OTError error) { }
050    }