![JAR search and dependency download from the Maven repository](/logo.png)
org.ice4j.StunFailureEvent Maven / Gradle / Ivy
/*
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
*
* Copyright @ 2015 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ice4j;
import org.ice4j.message.*;
import org.ice4j.stack.*;
/**
* The class is used to dispatch events that occur when a STUN transaction
* fails asynchronously for reasons like a port unreachable exception for
* example.
*
* @author Emil Ivov
*/
public class StunFailureEvent
extends BaseStunMessageEvent
{
/**
* Serial version UID for this Serializable class.
*/
private static final long serialVersionUID = 41232541L;
/**
* The Exception that caused this failure.
*/
private final Throwable cause;
/**
* Constructs a StunFailureEvent according to the specified
* message.
*
* @param stunStack the StunStack to be associated with the new
* instance
* @param message the message itself
* @param localAddress the local address that the message was sent from.
* @param cause the Exception that caused this failure or
* null if there's no Exception associated with this
* failure
*/
public StunFailureEvent(
StunStack stunStack,
Message message,
TransportAddress localAddress,
Throwable cause)
{
super(stunStack, localAddress, message);
this.cause = cause;
}
/**
* Returns the TransportAddress that the message was supposed to
* leave from.
*
* @return the TransportAddress that the message was supposed to
* leave from.
*/
public TransportAddress getLocalAddress()
{
return getSourceAddress();
}
/**
* Returns the Exception that cause this failure or null
* if the failure is not related to an Exception.
*
* @return the Exception that cause this failure or null
* if the failure is not related to an Exception.
*/
public Throwable getCause()
{
return cause;
}
/**
* Returns a String representation of this event, containing the
* corresponding message, and local address.
*
* @return a String representation of this event, containing the
* corresponding message, and local address.
*/
@Override
public String toString()
{
StringBuffer buff = new StringBuffer("StunFailureEvent:\n\tMessage=");
buff.append(getMessage());
buff.append(" localAddr=").append(getLocalAddress());
return buff.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy