On Sun, Nov 10, 2013 at 6:02 PM, Szabo Bogdan <[email protected]>wrote:
> Hi, > > My name is Szabo Bogdan, an experienced php developer and the author of > this extension: > > https://github.com/gedaiu/phpWs > > It's a web socket extension that extends php with web socket capabilities. > Currently it uses the apache functions to read data from the client, but I > want to change that in the future, because I don't want to make the > extension to be dependent on apache2. > > This is my first php extension and I am eager to get better so I will > appreciate your feedback to improve this extension. > Hello, some quick feedback: - get_header and get_sec can be declared as static - In functions that don't take parameters you should use zend_parse_parameters_none - PHP extensions don't commonly use C99 due to portability reasons (mainly Visual Studio I guess), hence variables should be declared at the beginning of the scope - Instead of the following construct: char *sec = emalloc((size_t) (strlen("Sec-WebSocket-Accept: ") + 100) ); sprintf(sec, "Sec-WebSocket-Accept: %s", target); you can use: spprintf (&sec, 0, "Sec-WebSocket-Accept: %s", target); spprintf dynamically e-allocates memory as needed. - In ws_send function you probably want to check the type of the object being passed, either provide an interface that has 'encode' method in it or force the type to be WsFrame. (See instanceof_function_ex) I didn't have time to dig deeper but I will have another look at some point. Thanks, Mikko
