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

Class: Net_Server_Handler

Source Location: /Net_Server-1.0.3/Net/Server/Handler.php

Class Overview


Base class for all handlers


Author(s):

Methods


Child classes:

Net_Server_Handler_Talkback
simple example that implements a talkback.

Inherited Variables

Inherited Methods


Class Details

[line 38]
Base class for all handlers


[ Top ]


Method Detail

onClose   [line 162]

null onClose( [integer $clientId = 0])

onClose handler

This handler is called, when a client disconnects from the server.

You could implement some garbage collection in this method.

Available in:

  • Net_Server_Sequential
  • Net_Server_Fork

  • Access: public

Parameters:

integer   $clientId   —  unique id of the client, in Net_Server_Fork, this is always 0

[ Top ]

onConnect   [line 119]

null onConnect( [integer $clientId = 0])

onConnect handler

This handler is called, when a new client connects. It is called even before the client sent data to the server.

You could use this method to send a welcome message to the client.

Available in:

  • Net_Server_Sequential
  • Net_Server_Fork

  • Access: public

Parameters:

integer   $clientId   —  unique id of the client, in Net_Server_Fork, this is always 0

[ Top ]

onConnectionRefused   [line 141]

null onConnectionRefused( [integer $clientId = 0])

onConnectionRefused handler

This handler is called, when a new client tries to connect but is not allowed to.

This could happen, if max clients is used. This method currently only may be implemented in Net_Server_Sequential. Will be available in other drivers soon.

Available in:

  • Net_Server_Sequential

  • Access: public

Parameters:

integer   $clientId   —  unique id of the client

[ Top ]

onReceiveData   [line 182]

null onReceiveData( [integer $clientId = 0], [string $data = ""])

onReceiveData handler

This handler is called, when a client sends data to the server

Available in:

  • Net_Server_Sequential
  • Net_Server_Fork

  • Access: public

Overridden in child classes as:

Net_Server_Handler_Talkback::onReceiveData()
If the user sends data, send it back to him

Parameters:

integer   $clientId   —  unique id of the client, in Net_Server_Fork, this is always 0
string   $data   —  data that the client sent

[ Top ]

onShutdown   [line 97]

null onShutdown( )

onShutdown handler

This handler is called, when the server is stopped.

Implement gabage collection in this method, if your server created some temporary files.

Available in:

  • Net_Server_Sequential

  • Access: public

[ Top ]

onStart   [line 79]

null onStart( )

onStart handler

This handler is called, when the server starts.

Implement this method to load configuration files.

Available in:

  • Net_Server_Sequential
  • Net_Server_Fork

  • Access: public

[ Top ]

setServerReference   [line 60]

null setServerReference( Net_Server_Driver &$server)

set a reference to the server object

This is done automatically when the handler is passed over to the server

  • Access: public

Parameters:

Net_Server_Driver   &$server   —  a reference to the driver object, needed to send data to the clients

[ Top ]


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