Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving from cocaine 11 to 12 #259

Open
bioothod opened this issue Jun 28, 2016 · 0 comments
Open

Moving from cocaine 11 to 12 #259

bioothod opened this issue Jun 28, 2016 · 0 comments

Comments

@bioothod
Copy link
Member

Hi

There is a question about moving apparently client app from 11 to 12 cocaine at reverbrain mail list, please take a look and reply both here and in the mailgroup

We are trying move from cocaine 11 to 12 and I'm investigating details. I didn't find any docs about writing applications with cocaine12 and examples are too simple.
Now I'm interested how properly send big array of bytes in chunks?

App:

worker.on("ping", [](worker::sender tx, worker::receiver rx) {
       std::cout << "After invoke" << std::endl;
       if (boost::optional<std::string> message = rx.recv().get()) { // app read one chunk
            std::cout << "After chunk: '" << *message << "'" << std::endl;
           tx.write(*message).get(); // app write one chunk
            std::cout << "After write" << std::endl;
       }
       std::cout << "After close" << std::endl;
   });

Client:

task<void>::future_type
on_invoke(task<channel<io::app::enqueue>>::future_move_type future) {
   auto channel = future.get();
   auto tx = std::move(channel.tx);
   auto rx = std::move(channel.rx);
   return tx.send<scope::chunk>("le message") // client write one chunk
        .then(trace_t::bind(&on_send, std::placeholders::_1, rx))
       .then(trace_t::bind(&on_chunk, std::placeholders::_1, rx)) // client read one chunk
        .then(trace_t::bind(&on_choke, std::placeholders::_1));
}

In this example I see how to send one chunk from client to app and backward. But what should I do if I want to send 3 chunks from client to app and after that 5 chunks from app to client?

https://groups.google.com/forum/#!topic/reverbrain/4VGLV2-yIac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant