Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Created June 20, 2016 07:08
Show Gist options
  • Save tomykaira/85e0653e318fd00b48c02a5d786a4f8f to your computer and use it in GitHub Desktop.
Save tomykaira/85e0653e318fd00b48c02a5d786a4f8f to your computer and use it in GitHub Desktop.
/* nghttp2_on_frame_recv_callback: Called when nghttp2 library
received a complete frame from the remote peer. */
static int on_frame_recv_callback(nghttp2_session *session,
const nghttp2_frame *frame, void *user_data) {
std::cout << "RECV:: ";
switch (frame->hd.type) {
case NGHTTP2_DATA:
std::cout << "NGHTTP2_DATA" << std::endl;
break;
case NGHTTP2_HEADERS:
std::cout << "NGHTTP2_HEADERS" << std::endl;
break;
case NGHTTP2_PRIORITY:
std::cout << "NGHTTP2_PRIORITY" << std::endl;
break;
case NGHTTP2_RST_STREAM:
std::cout << "NGHTTP2_RST_STREAM" << std::endl;
break;
case NGHTTP2_SETTINGS:
std::cout << "NGHTTP2_SETTINGS" << std::endl;
break;
case NGHTTP2_PUSH_PROMISE:
std::cout << "NGHTTP2_PUSH_PROMISE" << std::endl;
break;
case NGHTTP2_PING:
std::cout << "NGHTTP2_PING" << std::endl;
break;
case NGHTTP2_GOAWAY:
std::cout << "NGHTTP2_GOAWAY" << std::endl;
break;
case NGHTTP2_WINDOW_UPDATE:
std::cout << "NGHTTP2_WINDOW_UPDATE" << std::endl;
break;
case NGHTTP2_CONTINUATION:
std::cout << "NGHTTP2_CONTINUATION" << std::endl;
break;
case NGHTTP2_ALTSVC:
std::cout << "NGHTTP2_ALTSVC" << std::endl;
break;
}
return 0;
}
nghttp2_session_callbacks_set_on_frame_recv_callback(callbacks,
on_frame_recv_callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment