Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cf-dev] Multiple response to one request

Hi Laurent

The correct way to do this is using separate responses:

@Override
public void handlePUT(CoapExchange exchange) {
	// make it a separate response
	exchange.accept();

	// your long-lasting task
        
	// finish with the response
	exchange.respond(CHANGED); // reply with response code only (shortcut)
}

On the client side you can either use an asynchronous request with a CoapHandler or you run a synchronous request in a dedicated thread.

Ciao
Matthias

> -----Original Message-----
> From: cf-dev-bounces@xxxxxxxxxxx [mailto:cf-dev-bounces@xxxxxxxxxxx] On
> Behalf Of Laurent Lemke
> Sent: Freitag, 12. Dezember 2014 21:12
> To: cf-dev@xxxxxxxxxxx
> Subject: [cf-dev] Multiple response to one request
> 
> Hello everybody,
> 
> I'm currently using californium and I'm trying to have this kind of scenario, a
> client/server communication :
> - Client send a request which correspond to an action that take some time
> (so a POST or PUT, in my case it's a PUT..)
> - Server send a first response, indicating to the client that he will do the best
> for doing this action (kind of ACCEPTED code response) ... the action is
> perform and taking a lot of time ...
> - Server send a second response indicating that the action has been
> successfully perform.
> 
> But well, when i'm trying to do program it with Californium i got stuck.
> Basically, it seems that a client cannot get multiple response for one request,
> right ?
> I mean, i exclude the "observe" property which is not suitable in my case.
> Because as far as i know, observe rely to the GET verb.. and i'm using a PUT
> verb here.
> 
> A possible solution, correct me if i am wrong (or if it's not relevant),  would be
> to have an asynchronous handler that is associated to a token ?
> Because currently, the asynchronous handler handle just one request.
> 
> Best regards,
> 
> Laurent Lemke.
> 
> 
> /**
> * Laurent Lemke
> * Doctorant CIFRE - Orange Labs
> * Université de Grenoble: équipe ERODS (LIG) & équipe Synchrone
> (VERIMAG) */
> 
> _______________________________________________
> cf-dev mailing list
> cf-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit https://dev.eclipse.org/mailman/listinfo/cf-dev

Back to the top