Net_CDDB
[ class tree: Net_CDDB ] [ index: Net_CDDB ] [ all elements ]

Class: Net_CDDB_Server

Source Location: /Net_CDDB-0.3.0/CDDB/Server.php

Class Overview

Net_CDDB
   |
   --Net_CDDB_Server

CDDB Server (ALPHA QUALITY, *USE AT YOUR OWN RISK!*)


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: Net_CDDB

Net_CDDB::calculateDiscId()
Calculate a disc ID based on the track offsets and the disc length
Net_CDDB::debug()
Enables or disables debugging ( prints out all responses/requests )
Net_CDDB::_createProtocol()
Create a protocol instance of the given type with the given parameters
Net_CDDB::_debug()
Prints/logs debugging messages
Net_CDDB::_parseRecord()
Parse a CDDB style database record into an array
Net_CDDB::_parseResult()
Parse a result string returned by a CDDB query into an array

Class Details

[line 117]
CDDB Server (ALPHA QUALITY, *USE AT YOUR OWN RISK!*)

*** WARNING *** Use at your own risk, it doesn't work very well yet!

Current features:

  • CDDB protocol level 5
  • Multiple data sources: tell the server to read from a local filesystem, a remote HTTP CDDB server, a remote CDDBP server, a database (coming soon) etc.
  • Supports about half of the CDDB commands
  • Write and register your own 'hooks' which run when the CDDB server responds to commands
Known issues:
  • Extremelly lightly tested (use at your own risk!)
  • Command: 'motd' reports and incorrect last modified date
  • Lack of any error reporting...
  • Lack of any login/hello command support
  • Only supports protocol level 5
  • Only provides HTTP request support (no CDDBP or SMTP... yet)
You can write your own custom 'hooks' that get run a certain stages of the CDDB request/response process and register them with the ->registerHook() method. You can register multiple hooks at each stage of the process, and they will get run in the order you register them in.

Hooks should receive passed parameters by reference if they intend to modify commands/requests/responses. Hooks should return either a four element array which will be treated as the response (as below) or void if the server should continue to process the response.

  1.  $my_custom_response = array(
  2.      NET_CDDB_RESPONSE_OK// This could actually be *any* valid response code
  3.      'status message to be returned with the response code',
  4.      'any data the response returns (a cddb record, a list of matching records, a list of mirror sites, etc.)',
  5.      true// true if a '.' should be appended to the response as a terminating character, false otherwise
  6.      );

  • Author: Keith Palmer <Keith@UglySlug.com>
  • Todo: Probably have the Net_CDDB_Request_* classes have three methods: getHello(), getProto(), and getCmd() or something


[ Top ]


Class Variables

$_hook_cmds =

[line 157]

An array of function names to call as command hooks
  • Access: protected

Type:   array


[ Top ]

$_hook_request =

[line 149]

An array of function names to call as request hooks
  • Access: protected

Type:   array


[ Top ]

$_hook_resp =

[line 165]

An arra of function names to call as response hooks
  • Access: protected

Type:   array


[ Top ]

$_protocol =

[line 133]

Net_CDDB_Protocol_* object instance to use for data access
  • Access: protected

Type:   object


[ Top ]

$_request =

[line 125]

Net_CDDB_Request_* object instance to use for listening for requests
  • Access: protected

Type:   object


[ Top ]



Method Detail

__construct (Constructor)   [line 187]

Net_CDDB_Server __construct( string $request_dsn, string $protocol_dsn, [array $options = array()])

Constructor (PHP v5.x)
  • Access: public

Parameters:

string   $request_dsn   — 
string   $protocol_dsn   — 
array   $options   — 

[ Top ]

Net_CDDB_Server (Constructor)   [line 173]

Net_CDDB_Server Net_CDDB_Server( $request_dsn, $protocol_dsn, [ $options = array()])

Constructor (PHP v4.x)

Parameters:

   $request_dsn   — 
   $protocol_dsn   — 
   $options   — 

[ Top ]

registerHook   [line 345]

boolean registerHook( char $when, function $function)

Register a hook function

See the example file or the class description for more details. Custom hooks can be used to hook into CDDB server requests and implement custom behaviors or actions.

  • Access: public

Parameters:

char   $when   — 
function   $function   — 

[ Top ]

start   [line 233]

boolean start( )

Start the CDDB server
  • Todo: Listen forever support (daemon mode)
  • Access: public

[ Top ]

_cddbHello   [line 452]

void _cddbHello( )

Dummy placeholder for 'cddb hello' command
  • Access: protected

[ Top ]

_cddbLscat   [line 466]

void _cddbLscat( string $cmd, string $query, &$status, &$message, &$data, &$term)

Respond to the 'cddb lscat' CDDB command (list categories)
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 
   &$status   — 
   &$message   — 
   &$data   — 
   &$term   — 

[ Top ]

_cddbQuery   [line 536]

void _cddbQuery( string $cmd, string $query, &$status, &$message, &$data, &$term)

Respond to the 'cddb query ...' CDDB command
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 
   &$status   — 
   &$message   — 
   &$data   — 
   &$term   — 

[ Top ]

_cddbRead   [line 501]

void _cddbRead( string $cmd, string $query, &$status, &$message, &$data, &$term)

Respond to the 'cddb read ...' CDDB command
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 
   &$status   — 
   &$message   — 
   &$data   — 
   &$term   — 

[ Top ]

_createRequest   [line 206]

Net_CDDB_Request _createRequest( string $dsn, array $options)

Create a Net_CDDB_Request object instance
  • Return: Returns an instance of a subclass of Net_CDDB_Request (i.e: Net_CDDB_Request_HTTP instance)
  • Access: protected

Parameters:

string   $dsn   — 
array   $options   — 

[ Top ]

_doCommandHooks   [line 375]

boolean _doCommandHooks( &$cmd, string $cmd)

Execute the command hooks
  • Access: protected

Parameters:

string   $cmd   — 
   &$cmd   — 

[ Top ]

_doRequestHooks   [line 421]

boolean _doRequestHooks( &$arr_cmds, array $arr_cmds)

Execute the request hooks
  • Access: protected

Parameters:

array   $arr_cmds   — 
   &$arr_cmds   — 

[ Top ]

_doResponseHooks   [line 402]

boolean _doResponseHooks( string $cmd, &$status, &$message, &$data, &$term, integer $status, string $message, string $data, boolean $term)

Execute the response hooks
  • Access: protected

Parameters:

string   $cmd   — 
integer   $status   — 
string   $message   — 
string   $data   — 
boolean   $term   — 
   &$status   — 
   &$message   — 
   &$data   — 
   &$term   — 

[ Top ]

_motd   [line 566]

void _motd( string $cmd, string $query, &$status, &$message, &$data, &$term)

Respond to the CDDB 'motd' command
  • Todo: Find out the motd modified time somehow...?
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 
   &$status   — 
   &$message   — 
   &$data   — 
   &$term   — 

[ Top ]

_proto   [line 440]

void _proto( )

Dummy placeholder for the 'cddb proto' command
  • Access: protected

[ Top ]

_ver   [line 601]

void _ver( string $cmd, string $query, &$status, &$message, &$data, &$term)

Respond to the CDDB 'ver' command
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 
   &$status   — 
   &$message   — 
   &$data   — 
   &$term   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:56:54 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.