forked from walkor/workerman
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionInterface.php
More file actions
80 lines (71 loc) · 1.87 KB
/
Copy pathConnectionInterface.php
File metadata and controls
80 lines (71 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* 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
*/
namespace Workerman\Connection;
use Workerman\Events\Libevent;
use Workerman\Events\Select;
use Workerman\Events\EventInterface;
use Workerman\Worker;
use \Exception;
/**
* connection类的接口
*/
abstract class ConnectionInterface
{
/**
* status命令的统计数据
* @var array
*/
public static $statistics = array(
'connection_count'=>0,
'total_request' => 0,
'throw_exception' => 0,
'send_fail' => 0,
);
/**
* 当收到数据时,如果有设置$onMessage回调,则执行
* @var callback
*/
public $onMessage = null;
/**
* 当连接关闭时,如果设置了$onClose回调,则执行
* @var callback
*/
public $onClose = null;
/**
* 当出现错误时,如果设置了$onError回调,则执行
* @var callback
*/
public $onError = null;
/**
* 发送数据给对端
* @param string $send_buffer
* @return void|boolean
*/
abstract public function send($send_buffer);
/**
* 获得远端ip
* @return string
*/
abstract public function getRemoteIp();
/**
* 获得远端端口
* @return int
*/
abstract public function getRemotePort();
/**
* 关闭连接,为了保持接口一致,udp保留了此方法,当是udp时调用此方法无任何作用
* @void
*/
abstract public function close($data = null);
}