phpsocks5/Workerman/Connection/ConnectionInterface.php

84 lines
1.7 KiB
PHP
Raw Normal View History

2015-04-04 21:46:31 +08:00
<?php
2016-09-20 21:27:41 +08:00
/**
* This file is part of workerman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
2015-04-04 21:46:31 +08:00
namespace Workerman\Connection;
/**
2016-09-20 21:27:41 +08:00
* ConnectionInterface.
2015-04-04 21:46:31 +08:00
*/
abstract class ConnectionInterface
{
/**
2016-09-20 21:27:41 +08:00
* Statistics for status command.
*
2015-04-04 21:46:31 +08:00
* @var array
*/
public static $statistics = array(
2016-09-20 21:27:41 +08:00
'connection_count' => 0,
'total_request' => 0,
'throw_exception' => 0,
'send_fail' => 0,
2015-04-04 21:46:31 +08:00
);
2016-09-20 21:27:41 +08:00
2015-04-04 21:46:31 +08:00
/**
2016-09-20 21:27:41 +08:00
* Emitted when data is received.
*
2015-04-04 21:46:31 +08:00
* @var callback
*/
public $onMessage = null;
2016-09-20 21:27:41 +08:00
2015-04-04 21:46:31 +08:00
/**
2016-09-20 21:27:41 +08:00
* Emitted when the other end of the socket sends a FIN packet.
*
2015-04-04 21:46:31 +08:00
* @var callback
*/
public $onClose = null;
2016-09-20 21:27:41 +08:00
2015-04-04 21:46:31 +08:00
/**
2016-09-20 21:27:41 +08:00
* Emitted when an error occurs with connection.
*
2015-04-04 21:46:31 +08:00
* @var callback
*/
public $onError = null;
2016-09-20 21:27:41 +08:00
2015-04-04 21:46:31 +08:00
/**
2016-09-20 21:27:41 +08:00
* Sends data on the connection.
*
2015-04-04 21:46:31 +08:00
* @param string $send_buffer
* @return void|boolean
*/
abstract public function send($send_buffer);
2016-09-20 21:27:41 +08:00
2015-04-04 21:46:31 +08:00
/**
2016-09-20 21:27:41 +08:00
* Get remote IP.
*
2015-04-04 21:46:31 +08:00
* @return string
*/
abstract public function getRemoteIp();
2016-09-20 21:27:41 +08:00
2015-04-04 21:46:31 +08:00
/**
2016-09-20 21:27:41 +08:00
* Get remote port.
*
2015-04-04 21:46:31 +08:00
* @return int
*/
abstract public function getRemotePort();
/**
2016-09-20 21:27:41 +08:00
* Close connection.
*
* @param $data
* @return void
2015-04-04 21:46:31 +08:00
*/
abstract public function close($data = null);
}