* the message is an connection bind request a {@link ConnectionBindHandler}
* gets used to handle the message. If the message was of unknown type a bad
* request error is returned to the client.
*/
public void run() {
Message message;
try {
final MessageReader messageReader = this.createCustomRelayingMessageReader();
logger.debug("Reading incoming message from {}", s.toString()); //$NON-NLS-1$
message = messageReader.readSTUNMessage(s.getInputStream());
} catch (IOException e) {
logger.error("IOEXception while receiving message: {}", e.getMessage());
return;
}
if (message.isMethod(RelayingMethod.ALLOCATION) && message.isRequest()) {
logger.info("Received allocation request");
new RelayAllocationHandler(s, controlConnectionWriter, connIDToQueue, message,
controlConnectionHandlerExecutor, relayExecutor).handle();
} else if (message.isMethod(RelayingMethod.CONNECTION_BIND) && message.isRequest()) {
logger.info("Received connection bind");
new ConnectionBindHandler(s, message, connIDToQueue).handle();
} else {
// unknown message
logger.error("Received wrong message tye {}", message.getMessageMethod());
try {
Message errorResponse = message.buildFailureResponse(STUNErrorCode.BAD_REQUEST,
"Did not expect message " + message.getMessageMethod());
controlConnectionWriter.writeMessage(errorResponse);
} catch (IOException e) {
logger.error("IOException while sending error response");
}