Created
August 11, 2022 15:51
-
-
Save PeterCorless/436e3ee3eceb948e59564cb2834a7a9f to your computer and use it in GitHub Desktop.
WebSocket in Seastar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ws.register_handler("echo", [] (input_stream<char>& in, | |
output_stream<char>& out) { | |
return repeat([&in, &out]() { | |
return in.read().then([&out](temporary_buffer<char> f) { | |
std::cerr << "f.size(): " << f.size() << "\n"; | |
if (f.empty()) { | |
return make_ready_future<stop_iteration>(stop_iteration::yes); | |
} else { | |
return out.write(std::move(f)).then([&out]() { | |
return out.flush().then([] { | |
return make_ready_future<stop_iteration>(stop_iteration::no); | |
}); | |
}); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment