Package de.uniluebeck.itm.ncoap.communication.dispatching.client

Examples of de.uniluebeck.itm.ncoap.communication.dispatching.client.Token


     *
     * @throws IllegalArgumentException if the given message ID is out of the allowed range
     */
    public static CoapMessage createPing(int messageID) throws IllegalArgumentException{
        return new CoapMessage(MessageType.Name.CON.getNumber(), MessageCode.Name.EMPTY.getNumber(), messageID,
                new Token(new byte[0])){};
    }
View Full Code Here


            this.observationsLock.writeLock().lock();
            String message = "Webservice \"" + this.uriPath + "\" no longer available!";

            for(Observation observation : this.observations.values()){
                final InetSocketAddress remoteEndpoint = observation.getRemoteEndpoint();
                final Token token = observation.getToken();

                CoapResponse coapResponse = CoapResponse.createErrorResponse(MessageType.Name.NON,
                        MessageCode.Name.NOT_FOUND_404, message);
                coapResponse.setToken(token);
View Full Code Here


        @Override
        public void run(){
            InetSocketAddress remoteEndpoint = this.observation.getRemoteEndpoint();
            Token token = this.observation.getToken();
            int messageID = this.observation.getMessageID();

            try{
                ObservableWebservice.this.observationsLock.writeLock().lock();
View Full Code Here

            coapMessage = new CoapResponse(messageType, messageCode);
            coapMessage.setMessageType(messageType);
        }

        coapMessage.setMessageID(messageID);
        coapMessage.setToken(new Token(token));

        //Decode and set the options
        if(buffer.readableBytes() > 0){
            try {
                setOptions(coapMessage, buffer);
            }
            catch (OptionCodecException e) {
                e.setMessageID(messageID);
                e.setToken(new Token(token));
                e.setRemoteEndpoint(remoteEndpoint);
                e.setMessageType(messageType);

                throw e;
            }
View Full Code Here

    private CoapMessage coapMessage;
    private ChannelBuffer encodedMessage;

    public DecodeEncodedMessageTest(CoapMessage coapMessage) throws Exception {
        coapMessage.setMessageID(1234);
        coapMessage.setToken(new Token(new byte[]{1,2,3,4}));

        if(coapMessage.getMessageCodeName() == MessageCode.Name.POST){
            String payload = "Some arbitrary payload";
            coapMessage.setContent(payload.getBytes(CoapMessage.CHARSET), ContentFormat.TEXT_PLAIN_UTF8);
        }
View Full Code Here

        //Wait some time
        Thread.sleep(300);

        //Get message ID and token from received message
        int messageID = endpoint.getReceivedCoapMessages().values().iterator().next().getMessageID();
        Token token = endpoint.getReceivedCoapMessages().values().iterator().next().getToken();

        //write response #1
        CoapResponse response = new CoapResponse(MessageType.Name.ACK, MessageCode.Name.CONTENT_205);
        response.setMessageID(messageID);
        response.setToken(token);
View Full Code Here

        endpoint = new DummyEndpoint();

        serverSocket = new InetSocketAddress("localhost", server.getPort());

        URI serviceURI = new URI("coap", null, "localhost", server.getPort(), PATH, null, null);
        token = new Token(new byte[]{1, 2, 3, 4});
        messageID = 1;

        coapRequest1 = new CoapRequest(MessageType.Name.CON, MessageCode.Name.GET, serviceURI);
        coapRequest1.setMessageID(messageID);
        coapRequest1.setToken(token);
View Full Code Here

        //wait another some time to simulate request processing
        Thread.sleep(2000);

        //create seperate response to be sent by the message receiver
        Token token = endpoint.getReceivedCoapMessages().values().iterator().next().getToken();

        CoapResponse seperateResponse = new CoapResponse(MessageType.Name.CON, MessageCode.Name.CONTENT_205);
        seperateResponse.setMessageID(11111);
        seperateResponse.setToken(token);
        seperateResponse.setContent("Some payload...".getBytes(CoapMessage.CHARSET), ContentFormat.TEXT_PLAIN_UTF8);
View Full Code Here

        this.messageIDFactory.setChannel(ctx.getChannel());
     }


    private void addTransfer(InetSocketAddress remoteEndpoint, CoapMessage coapMessage, boolean reliable){
        Token token = coapMessage.getToken();
        int messageID = coapMessage.getMessageID();

        try{
            lock.writeLock().lock();
View Full Code Here

            OutboundMessageTransfer transfer = removeTransfer(remoteEndpoint, messageID);
            if(transfer != null){
                if(transfer instanceof OutboundReliableMessageTransfer){
                    log.info("Removed reliable transfer (remote endpoint: {}, message ID: {})", remoteEndpoint,
                            messageID);
                    Token token = transfer.getToken();
                    Channels.fireMessageReceived(ctx, new TransmissionTimeoutEvent(remoteEndpoint, messageID, token));
                }
                else{
                    log.info("Removed non-reliable transfer (remote endpoint: {}, message ID: {})", remoteEndpoint,
                            messageID);
View Full Code Here

TOP

Related Classes of de.uniluebeck.itm.ncoap.communication.dispatching.client.Token

Copyright © 2018 www.massapicom. 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.