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

Class: Net_Server_Driver_Sequential

Source Location: /Net_Server-1.0.3/Net/Server/Driver/Sequential.php

Class Overview

PEAR
   |
   --Net_Server_Driver
      |
      --Net_Server_Driver_Sequential

Sequential server class.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: Net_Server_Driver

Net_Server_Driver::getEndCharacter()
Returns the readEndCharacter setting.
Net_Server_Driver::getLastSocketError()
return string for last socket error
Net_Server_Driver::setCallbackObject()
register a callback object
Net_Server_Driver::setDebugMode()
Set debug mode
Net_Server_Driver::setEndCharacter()
Sets the readEndCharacter setting.
Net_Server_Driver::_sendDebugMessage()
send a debug message

Class Details

[line 60]
Sequential server class.

This class will handles all connection in one server process. This allows you to build servers, where communication between the clients is easy. The drawback is that clients are served sequentially (hence the name). If you send large blocks of data to a client, the others will have to wait. For servers where communication between clients is not needed, use Net_Server_Fork instead.

Events that can be handled:

  • onStart
  • onConnect
  • onConnectionRefused
  • onClose
  • onReceiveData
  • onShutdown



[ Top ]


Class Variables

$clients =  0

[line 66]

amount of clients

Type:   integer


[ Top ]

$idleTimeout =  null

[line 73]

Seconds until the idle handler is called.

If set to NULL, the idle handler is deactivated.


Type:   integer


[ Top ]



Method Detail

broadcastData   [line 376]

null broadcastData( string $data, [array $exclude = array()])

send data to all clients
  • Access: public

Parameters:

string   $data   —  data to send
array   $exclude   —  client ids to exclude

[ Top ]

closeConnection   [line 423]

null closeConnection( [int $id = 0])

close connection to a client
  • Access: public

Parameters:

int   $id   —  internal ID of the client

[ Top ]

getClientInfo   [line 407]

array getClientInfo( int $clientId)

get current information about a client
  • Return: information about the client
  • Access: public

Parameters:

int   $clientId   —  ID of the client

[ Top ]

getClients   [line 329]

int getClients( )

get current amount of clients
  • Return: amount of clients
  • Access: public

[ Top ]

isConnected   [line 315]

boolean isConnected( integer $id)

check, whether a client is still connected
  • Return: true if client is connected, false otherwise
  • Access: public

Parameters:

integer   $id   —  client id

[ Top ]

sendData   [line 346]

null sendData( int $clientId, string $data, [boolean $debugData = true])

send data to a client
  • Access: public

Parameters:

int   $clientId   —  ID of the client
string   $data   —  data to send
boolean   $debugData   —  flag to indicate whether data that is written to socket should also be sent as debug message

[ Top ]

setIdleTimeout   [line 105]

null setIdleTimeout( [int $idleTimeout = null])

Set the number of seconds until the idle handler is called (if defined).

If the timeout is set to NULL (or 0), the timeout is deactivated.

The idle handler function is "onIdle" and takes no parameters.

Please take care when using timeout handlers, as the PHP manual states: You should always try to use socket_select() without timeout. Your program should have nothing to do if there is no data available. Code that depends on timeouts is not usually portable and difficult to debug.

  • Access: public

Parameters:

int   $idleTimeout   —  Number of seconds until the timeout handler is called.

[ Top ]

setMaxClients   [line 83]

null setMaxClients( int $maxClients)

set maximum amount of simultaneous connections
  • Access: public

Parameters:

int   $maxClients   —  Maximum connections

[ Top ]

shutDown   [line 453]

null shutDown( )

shutdown server
  • Access: public

[ Top ]

start   [line 119]

null start( )

start the server
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:47:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.