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

Examples of de.fhkn.in.uce.stun.message.MessageWriter.writeMessage()


                    s.connect(relayServerEndpoint);
                    MessageWriter dataConnectionWriter = new MessageWriter(s.getOutputStream());
                    Message connectionBindRequestMessage = MessageStaticFactory.newSTUNMessageInstance(
                            STUNMessageClass.REQUEST, RelayingMethod.CONNECTION_BIND);
                    connectionBindRequestMessage.addAttribute(new Token(message.getAttribute(Token.class).getToken()));
                    dataConnectionWriter.writeMessage(connectionBindRequestMessage);
                    // TODO erfolgs oder fehlermeldung abwarten
                    socketQueue.add(s);
                } else if (message.isMethod(STUNMessageMethod.KEEP_ALIVE) && message.isSuccessResponse()) {
                    int lifetime = message.getAttribute(RelayingLifetime.class).getLifeTime();
                    logger.debug("Received lifetime response {}", lifetime);
View Full Code Here


    private void sendBindingRequestToStunServer(final OutputStream out) throws Exception {
        final MessageWriter writer = new MessageWriter(out);
        final Message request = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.BINDING);
        writer.writeMessage(request);
    }

    private Message receiveBindingResponseFromStunServer(final InputStream in) throws Exception {
        final MessageReader reader = MessageReader.createMessageReader();
        return reader.readSTUNMessage(in);
View Full Code Here

                && receivedMessage.hasAttribute(Token.class)) {
            final Token receivedToken = receivedMessage.getAttribute(Token.class);
            if (receivedToken.getToken().equals(this.authentikationToken)) {
                final Message tokenAckMessage = receivedMessage.buildSuccessResponse();
                synchronized (sharedLock) {
                    messageWriter.writeMessage(tokenAckMessage);
                    final Message receveidAckMessage = messageReader
                            .readSTUNMessage(toBeAuthenticated.getInputStream());
                    if (this.hpUtil.isAuthenticationAcknowledgmentMessage(receveidAckMessage)) {
                        logger.debug("Authentication successfull, stopping hole punching threads"); //$NON-NLS-1$
                        this.hpUtil.stopCancableTasksExceptOwnTask(relatedHolePunchingTasks, ownTask);
View Full Code Here

            registerMessage.addAttribute(new XorMappedAddress(new InetSocketAddress(this.socketToMediator
                    .getLocalAddress(), this.socketToMediator.getLocalPort())));
        }
        final MessageWriter messageWriter = new MessageWriter(this.socketToMediator.getOutputStream());
        logger.info("Sending RegisterMessage for {}", this.targetId); //$NON-NLS-1$
        messageWriter.writeMessage(registerMessage);
    }

    @SuppressWarnings("unused")
    private Message receiveMessage() throws IOException {
        final MessageReader messageReader = MessageReader.createMessageReader();
View Full Code Here

        connectionRequestMessage.addAttribute(new HolePunchingAttribute());
        connectionRequestMessage.addAttribute(new Username(targetId));
        final InetSocketAddress localAddress = (InetSocketAddress) controlConnection.getLocalSocketAddress();
        connectionRequestMessage.addAttribute(new XorMappedAddress(localAddress));
        connectionRequestMessage.addAttribute(authentificationToken);
        messageWriter.writeMessage(connectionRequestMessage);
    }

    private Message receiveMessage(final Socket controlConnection) throws IOException {
        final MessageReader messageReader = this.hpUtil.getCustomHolePunchingMessageReader();
        return messageReader.readSTUNMessage(controlConnection.getInputStream());
View Full Code Here

        // sending authentication message
        final Message authenticationMessage = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.AUTHENTICATE);
        authenticationMessage.addAttribute(new Token(this.authentikationToken));
        logger.info("Sending AuthenticationMessage: {}", authenticationMessage); //$NON-NLS-1$
        messageWriter.writeMessage(authenticationMessage);
        // receiving authentication acknowledgment message
        final Message reveivedAckMessage = messageReader.readSTUNMessage(toBeAuthenticated.getInputStream());
        if (this.hpUtil.isAuthenticationAcknowledgmentMessage(reveivedAckMessage)) {
            synchronized (sharedLock) {
                // sending second authentication acknowledgment message
View Full Code Here

        final Message reveivedAckMessage = messageReader.readSTUNMessage(toBeAuthenticated.getInputStream());
        if (this.hpUtil.isAuthenticationAcknowledgmentMessage(reveivedAckMessage)) {
            synchronized (sharedLock) {
                // sending second authentication acknowledgment message
                final Message secondAckMessage = reveivedAckMessage.buildSuccessResponse();
                messageWriter.writeMessage(secondAckMessage);
                logger.debug("Authentication successfull, stopping hole punching threads"); //$NON-NLS-1$
                this.hpUtil.stopCancableTasksExceptOwnTask(relatedHolePunchingTasks, ownTask);
                result = true;
            }
        }
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.