/*
* Sun Public License
*
* The contents of this file are subject to the Sun Public License Version
* 1.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is available at http://www.sun.com/
*
* The Original Code is the SLAMD Distributed Load Generation Engine.
* The Initial Developer of the Original Code is Neil A. Wilson.
* Portions created by Neil A. Wilson are Copyright (C) 2004-2010.
* Some preexisting portions Copyright (C) 2002-2006 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Contributor(s): Neil A. Wilson
*/
package com.slamd.protocol;
import java.util.HashMap;
import com.slamd.asn1.ASN1Element;
import com.slamd.asn1.ASN1Null;
import com.slamd.common.SLAMDException;
/**
* This class defines a SLAMD message with no real payload, which is used to
* ensure that the communication between the client and the server remains
* valid. It can be used to help prevent network hardware from "timing out" an
* idle connection, and it can also be used to verify that an existing
* connection is still valid (because an error would be generated if the attempt
* to send it failed).
*
*
* @author Neil A. Wilson
*/
public class KeepAlive
extends SLAMDMessage
{
/**
* Creates a new instance of this keepalive message with the provided
* information.
*
* @param messageID The message ID for this SLAMD message.
* @param extraProperties The "extra" properties for this SLAMD message.
* Both the names and values for the properties must
* be strings.
*/
public KeepAlive(int messageID, HashMap<String,String> extraProperties)
{
super(messageID, extraProperties);
}
/**
* Encodes the payload component of this SLAMD message to an ASN.1 element for
* inclusion in the message envelope.
*
* @return The ASN.1 element containing the encoded message payload.
*/
@Override()
public ASN1Element encodeMessagePayload()
{
// There is no real payload for a keepalive message.
return new ASN1Null();
}
/**
* Decodes the provided ASN.1 element and uses it as the payload for this
* SLAMD message.
*
* @param payloadElement The ASN.1 element to decode as the payload for this
* SLAMD message.
*
* @throws SLAMDException If a problem occurs while attempting to decode the
* provided ASN.1 element as the payload for this
* SLAMD message.
*/
@Override()
public void decodeMessagePayload(ASN1Element payloadElement)
throws SLAMDException
{
// No action is required, since there should not be any real payload.
}
/**
* Appends a string representation of the payload for this SLAMD message to
* the provided buffer. The string representation may contain multiple lines,
* but the last line should not end with an end-of-line marker.
*
* @param buffer The buffer to which the string representation is to be
* appended.
* @param indent The number of spaces to indent the payload content.
*/
@Override()
public void payloadToString(StringBuilder buffer, int indent)
{
// No action is required, since there is no payload.
}
}