Package de.fhkn.in.uce.stun.message

Examples of de.fhkn.in.uce.stun.message.Message.writeTo()


        final InetSocketAddress targetEndpoint = new InetSocketAddress(controlConnection.getInetAddress(),
                controlConnection.getPort());
        logger.debug("Sending connection request response with {} to source", targetEndpoint.toString()); //$NON-NLS-1$
        successResponse.addAttribute(new XorMappedAddress(targetEndpoint));
        successResponse.addAttribute(new EndpointClass(EndpointCategory.PUBLIC));
        successResponse.writeTo(connReq.getControlConnection().getOutputStream());
    }

    private void callTarget(final UserData target, final Message connectionRequestFromSource) throws Exception {
        logger.debug("Calling target {}", target.getUserId()); //$NON-NLS-1$
        final Socket toTarget = target.getSocketToUser();
View Full Code Here


        final Socket toTarget = target.getSocketToUser();
        final Message connectionRequest = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.CONNECTION_REQUEST, connectionRequestFromSource.getHeader().getTransactionId());
        connectionRequest.addAttribute(new DirectconnectionAttribute());
        logger.debug("Forwarding connection request to target"); //$NON-NLS-1$
        connectionRequest.writeTo(toTarget.getOutputStream());
    }

    private void sendFailureResponse(final Message message, final String errorReaon, final STUNErrorCode errorCode,
            final OutputStream out) throws Exception {
        logger.debug(errorReaon);
View Full Code Here

    private void sendFailureResponse(final Message message, final String errorReaon, final STUNErrorCode errorCode,
            final OutputStream out) throws Exception {
        logger.debug(errorReaon);
        final Message failureResponse = message.buildFailureResponse(errorCode, errorReaon);
        failureResponse.writeTo(out);
    }

    @Override
    public NATTraversalTechniqueAttribute getAttributeForTraversalTechnique() {
        return new DirectconnectionAttribute();
View Full Code Here

        logger.debug("Sending connection request"); //$NON-NLS-1$
        final Message requestConnectionMessage = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.CONNECTION_REQUEST);
        requestConnectionMessage.addAttribute(new Username(targetId));
        requestConnectionMessage.addAttribute(new RelayingAttribute());
        requestConnectionMessage.writeTo(controlConnection.getOutputStream());
    }

    private Message receiveConnectionResponse(final Socket controlConnection) throws IOException {
        final MessageReader messageReader = MessageReader.createMessageReader();
        return messageReader.readSTUNMessage(controlConnection.getInputStream());
View Full Code Here

                    response.getHeader().getTransactionId()).getInt());
        } else {
            endpointAtRelayAttribute = new XorMappedAddress(endpointAtRelay);
        }
        response.addAttribute(endpointAtRelayAttribute);
        response.writeTo(controlConnection.getOutputStream());
    }

    @Override
    public void registerTargetAtMediator(final String targetId, final Socket controlConnection) throws Exception {
        // can be used to use traversal technique without connectivity manager
View Full Code Here

            } else {
                logger.error("Connection id (" + connectionId + ") does not refer to an existing pending connection.");
                try {
                    Message errorResponse = connBindMessage.buildFailureResponse(STUNErrorCode.BAD_REQUEST,
                            "Connection ID (" + connectionId + ") does not refer to an existing pending connection.");
                    errorResponse.writeTo(s.getOutputStream());
                } catch (IOException e) {
                    logger.error("IOException while sending Error Response: {}", e);
                }
            }
        } else {
View Full Code Here

            logger.error("Received Connection Bind Message without Connection ID");
            try {
                Message errorResponse = connBindMessage.buildFailureResponse(STUNErrorCode.BAD_REQUEST,
                        "Connection Bind Message did not contain Connection ID.");

                errorResponse.writeTo(s.getOutputStream());
            } catch (IOException e) {
                logger.error("IOException while sending Error Response: {}", e);
            }
        }
    }
View Full Code Here

    private void sendConnectionRequest(final String targetId, final Socket controlConnection) throws Exception {
        final Message requestConnectionMessage = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.CONNECTION_REQUEST);
        requestConnectionMessage.addAttribute(new DirectconnectionAttribute());
        requestConnectionMessage.addAttribute(new Username(targetId));
        requestConnectionMessage.writeTo(controlConnection.getOutputStream());
    }

    private InetSocketAddress processConnectionRequestResponse(final Socket controlConnection) throws Exception {
        InetSocketAddress result;
        final MessageReader messageReader = MessageReader.createMessageReader();
View Full Code Here

        try {
            final Message keepAliveMessage = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                    STUNMessageMethod.KEEP_ALIVE);
            final Username userNameAttribute = new Username(this.targetId);
            keepAliveMessage.addAttribute(userNameAttribute);
            keepAliveMessage.writeTo(this.controlConnection.getOutputStream());
        } catch (final Exception e) {
            logger.error("Exception while sending keep-alive message: {}", e.getMessage()); //$NON-NLS-1$
        }
    }
}
View Full Code Here

    private void sendResponseForTargetIsReady(final Socket controlConnection, final Message connectionRequestMessage)
            throws IOException {
        final Message response = connectionRequestMessage.buildSuccessResponse();
        response.addAttribute(new DirectconnectionAttribute());
        response.writeTo(controlConnection.getOutputStream());
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.