|
|
|
@ -89,8 +89,6 @@ PHP_METHOD(Server, __construct) { |
|
|
|
|
if (args_array == NULL) { |
|
|
|
|
server->wrapped = grpc_server_create(NULL, NULL); |
|
|
|
|
} else { |
|
|
|
|
//TODO(thinkerou): deal it if key of array is long, crash now on php7
|
|
|
|
|
// and update unit test case
|
|
|
|
|
php_grpc_read_args_array(args_array, &args TSRMLS_CC); |
|
|
|
|
server->wrapped = grpc_server_create(&args, NULL); |
|
|
|
|
efree(args.args); |
|
|
|
@ -118,8 +116,8 @@ PHP_METHOD(Server, requestCall) { |
|
|
|
|
grpc_call_details_init(&details); |
|
|
|
|
grpc_metadata_array_init(&metadata); |
|
|
|
|
error_code = |
|
|
|
|
grpc_server_request_call(server->wrapped, &call, &details, &metadata, |
|
|
|
|
completion_queue, completion_queue, NULL); |
|
|
|
|
grpc_server_request_call(server->wrapped, &call, &details, &metadata, |
|
|
|
|
completion_queue, completion_queue, NULL); |
|
|
|
|
if (error_code != GRPC_CALL_OK) { |
|
|
|
|
zend_throw_exception(spl_ce_LogicException, "request_call failed", |
|
|
|
|
(long)error_code TSRMLS_CC); |
|
|
|
@ -140,25 +138,12 @@ PHP_METHOD(Server, requestCall) { |
|
|
|
|
php_grpc_add_property_string(result, "host", host_text, true); |
|
|
|
|
gpr_free(method_text); |
|
|
|
|
gpr_free(host_text); |
|
|
|
|
#if PHP_MAJOR_VERSION < 7 |
|
|
|
|
add_property_zval(result, "call", grpc_php_wrap_call(call, true TSRMLS_CC)); |
|
|
|
|
add_property_zval(result, "absolute_deadline", |
|
|
|
|
grpc_php_wrap_timeval(details.deadline TSRMLS_CC)); |
|
|
|
|
add_property_zval(result, "metadata", grpc_parse_metadata_array(&metadata |
|
|
|
|
TSRMLS_CC)); |
|
|
|
|
#else |
|
|
|
|
zval zv_call; |
|
|
|
|
zval zv_timeval; |
|
|
|
|
zval zv_md; |
|
|
|
|
//TODO(thinkerou): why use zval* to unit test error?
|
|
|
|
|
zv_call = *grpc_php_wrap_call(call, true); |
|
|
|
|
zv_timeval = *grpc_php_wrap_timeval(details.deadline); |
|
|
|
|
zv_md = *grpc_parse_metadata_array(&metadata); |
|
|
|
|
|
|
|
|
|
add_property_zval(result, "call", &zv_call); |
|
|
|
|
add_property_zval(result, "absolute_deadline", &zv_timeval); |
|
|
|
|
add_property_zval(result, "metadata", &zv_md); |
|
|
|
|
#endif |
|
|
|
|
php_grpc_add_property_zval(result, "call", |
|
|
|
|
grpc_php_wrap_call(call, true TSRMLS_CC)); |
|
|
|
|
php_grpc_add_property_zval(result, "absolute_deadline", |
|
|
|
|
grpc_php_wrap_timeval(details.deadline TSRMLS_CC)); |
|
|
|
|
php_grpc_add_property_zval(result, "metadata", |
|
|
|
|
grpc_parse_metadata_array(&metadata TSRMLS_CC)); |
|
|
|
|
|
|
|
|
|
cleanup: |
|
|
|
|
grpc_call_details_destroy(&details); |
|
|
|
@ -202,9 +187,9 @@ PHP_METHOD(Server, addSecureHttp2Port) { |
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO", &addr, &addr_len, |
|
|
|
|
&creds_obj, grpc_ce_server_credentials) == |
|
|
|
|
FAILURE) { |
|
|
|
|
zend_throw_exception( |
|
|
|
|
spl_ce_InvalidArgumentException, |
|
|
|
|
"add_http2_port expects a string and a ServerCredentials", 1 TSRMLS_CC); |
|
|
|
|
zend_throw_exception(spl_ce_InvalidArgumentException, |
|
|
|
|
"add_http2_port expects a string and a " |
|
|
|
|
"ServerCredentials", 1 TSRMLS_CC); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
wrapped_grpc_server_credentials *creds = |
|
|
|
|