diff --git a/CMakeLists.txt b/CMakeLists.txt index f66c722..36cdf38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ set(SOURCE_FILES sub.h pub.c pub.h + message.h + message.c ) diff --git a/command.h b/command.h index b017355..0682a34 100644 --- a/command.h +++ b/command.h @@ -15,7 +15,7 @@ */ #ifndef STRUGGLE_NSQ_MESSAGE_CLIENT_C_H -#define STRUGGLE_NSQ_MESSAGE_CLIENT_C_H char * request(char * url); +#define STRUGGLE_NSQ_MESSAGE_CLIENT_C_H void nsq_subscribe(struct bufferevent *bev, const char *topic, const char *channel); diff --git a/examples/pub.php b/examples/pub.php index 67ee1c1..a5507ef 100644 --- a/examples/pub.php +++ b/examples/pub.php @@ -2,7 +2,7 @@ //the nsqd tcp addr that you want to publish $nsqdAddr = array( "127.0.0.1:4150", //tcp addr - "127.0.0.1:4154", + //"127.0.0.1:4154", if you have another nsqd addr ); $nsq = new Nsq(); $isTrue = $nsq->connectNsqd($nsqdAddr); diff --git a/examples/sub.php b/examples/sub.php index 7e0c744..aaf4eb2 100644 --- a/examples/sub.php +++ b/examples/sub.php @@ -13,6 +13,7 @@ "retry_delay_time" => 5000, // after 5000 msec, message will be retried "auto_finish" => true, ); +//new NsqMessage(); $nsq->subscribe($nsq_lookupd, $config, function($msg,$bev){ diff --git a/message.c b/message.c index d91aac4..08287e0 100644 --- a/message.c +++ b/message.c @@ -15,8 +15,9 @@ */ #include -#include #include "ext/standard/php_var.h" +#include +#include #include "command.h" zend_class_entry *nsq_message_ce; @@ -88,7 +89,7 @@ static const zend_function_entry nsq_message_functions[] = { }; -void message_init(){ +void nsq_message_init() { zend_class_entry nsq_message; INIT_CLASS_ENTRY(nsq_message,"NsqMessage",nsq_message_functions); nsq_message_ce = zend_register_internal_class(&nsq_message TSRMLS_CC); diff --git a/message.h b/message.h new file mode 100644 index 0000000..b6fa50d --- /dev/null +++ b/message.h @@ -0,0 +1,25 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2017 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Zhenyu Wu | + +----------------------------------------------------------------------+ +*/ + + + +#ifndef STRUGGLE_NSQ_MESSAGE_H_CLIENT +#define STRUGGLE_NSQ_MESSAGE_H_CLIENT + +void nsq_message_init(); +//extern int le_bufferevent; + +#endif \ No newline at end of file diff --git a/nsq.c b/nsq.c index df8d78c..6391567 100644 --- a/nsq.c +++ b/nsq.c @@ -29,11 +29,12 @@ #include #include #include -#include +#include #include "ext/standard/php_string.h" #include "sub.h" #include "pub.h" +#include "message.h" #include "nsq_lookupd.h" #include "zend_exceptions.h" //#include @@ -599,9 +600,8 @@ PHP_MINIT_FUNCTION (nsq) zend_declare_property_null(nsq_ce, ZEND_STRL("nsqd_connection_fds"), ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_null(nsq_ce, ZEND_STRL("conn_timeout"), ZEND_ACC_PUBLIC TSRMLS_CC); le_bufferevent = zend_register_list_destructors_ex(_php_bufferevent_dtor, NULL, "buffer event", module_number); - lookupd_init(); - message_init(); + nsq_message_init(); return SUCCESS; } diff --git a/nsq_lookupd.c b/nsq_lookupd.c index c0a58eb..5a272b0 100644 --- a/nsq_lookupd.c +++ b/nsq_lookupd.c @@ -15,7 +15,6 @@ */ #include -#include "nsq_lookupd.h" #include #include #include @@ -45,7 +44,7 @@ ZEND_END_ARG_INFO() static PHP_METHOD(NsqLookupd, __construct); -static zend_class_entry *nsq_lookupd_ce; +zend_class_entry *nsq_lookupd_ce; static const zend_function_entry nsq_lookupd_functions[] = { PHP_ME(NsqLookupd, __construct, ctor, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) diff --git a/nsq_lookupd.h b/nsq_lookupd.h index b13a1a2..52e5f35 100644 --- a/nsq_lookupd.h +++ b/nsq_lookupd.h @@ -15,7 +15,9 @@ */ #ifndef STRUGGLE_NSQ_LOOKUP_CLIENT_C_H -#define STRUGGLE_NSQ_LOOKUP_CLIENT_C_H char * request(char * url); +#define STRUGGLE_NSQ_LOOKUP_CLIENT_C_H + +char * request(char * url); void lookupd_init(); diff --git a/package.xml b/package.xml index 705af00..96acfbe 100644 --- a/package.xml +++ b/package.xml @@ -15,9 +15,9 @@ 936321732@qq.com yes - 2019-09-17 + 2019-10-15 - 3.4.3 + 3.5.0 2.0.0 @@ -26,8 +26,7 @@ PHP - * Fix the problem of sub-processes not restarting automatically in CentOS environment - * this version is Stable + * Fix the bug in MacOs @@ -48,6 +47,7 @@ + diff --git a/php_nsq.h b/php_nsq.h index fec2a5e..2c8ca96 100644 --- a/php_nsq.h +++ b/php_nsq.h @@ -20,7 +20,7 @@ extern zend_module_entry nsq_module_entry; #define phpext_nsq_ptr &nsq_module_entry -#define PHP_NSQ_VERSION "3.4.3" /* Replace with version number for your extension */ +#define PHP_NSQ_VERSION "3.5.0" /* Replace with version number for your extension */ #ifdef PHP_WIN32 # define PHP_NSQ_API __declspec(dllexport) @@ -37,7 +37,6 @@ extern zend_module_entry nsq_module_entry; #define get_object_handle(object) Z_OBJ_HANDLE_P(object) -void message_init(); void error_handlings(char *message);