[Network] add stream socket client class

Review Request #10 — Created Nov. 5, 2012 and discarded

olivier
Lunr
personal/olivier/streamclient
12249
lunr
Add StreamSocketClient class extending StreamSocket

implements all abstract methods from StreamSocket
PHPUnit tests passed

Live test for push to APNS
  • 1
  • 0
  • 8
  • 0
  • 9
Description From Last Updated
I don't like this line, there's way too much going on pprkut pprkut
pprkut
  1. You currently require that open() and close() are called explicitely, while in other classes in Lunr we do it transparently.
    If you do it transparently you can also do the is open/closed checks a bit easier.
    For an example of what I'm talking about check the database connection classes.
  2. This needs to implement HttpRequestInterface
  3. 
      
olivier
olivier
olivier
pprkut
  1. There's changes in this review that are already present in other review requests. Please rediff properly.
  2. 
      
olivier
pprkut
  1. 
      
  2. system/libraries/network/class.streamsocketclient.inc.php (Diff revision 4)
     
     
     
     
     
     
     
    why would I be interested in this?
    1. right, only the http_response header is interesting
    2. I doubt I'm even interested in that. Why would I want to have access to low level http stuff. That's what I have the library for to not have to care
    3. For this one I insist can be usefull for debug purpose
  3. come again?
    1. Binary OR applied to flags array to construct the flags property... Is there an easier way to do  it??
    2. Ok, after reading the docs I can understand what you want to do. The foreach is fine, but
      
      $flags = 0;
      
      before is confusing. Use the proper default constant there (STREAM_CLIENT_CONNECT).
    3. The flag you mention is added in the constructor of the class.
      
      Initing to zero is made for allowing the possibility to remove that flag
      using the method remove_flag.
    4. Right, I didn't see that. But that's confusing to the user. Why should I have to remove something I never added?
      I would drop remove_flag(), detect whether flags are set or not. If not use STREAM_CLIENT_CONNECT, if they are use array_reduce() in combination with a lambda function (should be fairly small) to create the flags parameter.
    5. Ok so, then the default flag will be added if no flag present, remove_flag method will be suppressed.
    6. yes
  4. system/libraries/network/class.streamsocketclient.inc.php (Diff revision 4)
     
     
     
     
     
     
     
     
    we don't need the line breaking here
    1. will be removed then
    2. I like the line breaking in array generation, makes things more clear... and my auto formatter supports it! :P
    3. We can keep the line breaking, but then it needs to be proper:
      
      $this->handle = stream_socket_client(
          $this->remote_socket,
          $this->errno,
          $this->errmsg,
          $this->init_timeout,
          $flags,
          $this->context
      );
    4. Agree!
    5. I'll do but I dont like it!
  5. Instead of checking whether this is a handle, you can just introduce a boolean and check whether that is TRUE or FALSE
    1. you mean  if($this->handle) ?
    2. I mean if ($this->open) or if ($this->connected) or if ($this->started) ....
    3. Ok I get it now, that flag would be then set in the create handle method.
      Cleaner design.
      
      I propose to use the open name(started not relevant, connected depends on server side).
  6. system/libraries/network/class.streamsocketclient.inc.php (Diff revision 4)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    superfluous, look at parse_url()
    1. Ok will be made so
  7. I don't like this line, there's way too much going on
    1. In fact I caught the function from the documentation,
      it's a quick alternative to implementing PECL.
      I will have a look for making the function more readable.
      
      http://php.net/manual/fr/function.http-chunked-decode.php
    2. - Please try to do so
      - Please don't link to french documentation :P
  8. 
      
olivier
Review request changed

Status: Discarded

Change Summary:

replaced by http://reviews.lunr.nl/r/36/
Loading...