PHP Class Swoole\Protocol\WebSocket

Inheritance: extends HttpServer
Afficher le fichier Open project: matyhtf/swoole_framework Class Usage Examples

Méthodes publiques

Свойство Type Description
$connections
$frame_list
$heart_time 数据包最大长度,超过此长度会被认为是非法请求
$keepalive 600s life time
$max_connect
$max_frame_size

Méthodes publiques

Méthode Description
afterResponse ( Request $request, Response $response ) Clean and fire onWsConnect().
cleanBuffer ( $fd ) 清理连接缓存区
cleanConnection ( ) clean all connection
close ( integer $fd, integer $code = self::CLOSE_NORMAL, string $reason = '' ) : boolean Close a connection.
doHandshake ( Request $request, Response $response ) : boolean Do the handshake.
newFrame ( string $message, integer $opcode = self::OPCODE_TEXT_FRAME, boolean $end = true ) : integer Write a frame.
onClose ( $serv, $client_id, $from_id )
onConnect ( $serv, $fd, $from_id )
onEnter ( $client_id )
onExit ( $client_id ) : mixed 客户端退出
onHttpRequest ( Request $request ) : Response Produce response for Http request.
onMessage ( $client_id, $message ) : mixed 收到消息
onReceive ( $server, $fd, $from_id, $data ) Read a frame.
onRequest ( Request $request ) : Response Request come
onWebSocketRequest ( Request $request ) : Response Produce response for WebSocket request.
onWsConnect ( $client_id, $request ) Called on WebSocket connection established.
opcodeSwitch ( $client_id, &$ws ) opcode switch
parseFrame ( &$buffer ) : array | boolean 解析数据帧 返回false表示解析失败,需要关闭此连接
send ( integer $client_id, string $message, integer $opcode = self::OPCODE_TEXT_FRAME, boolean $end = true ) : boolean Send a message.

Méthodes protégées

Méthode Description
parseMessage ( $ws )

Method Details

afterResponse() public méthode

Clean and fire onWsConnect().
public afterResponse ( Request $request, Response $response )
$request Swoole\Request
$response Swoole\Response

cleanBuffer() public méthode

清理连接缓存区
public cleanBuffer ( $fd )
$fd

cleanConnection() public méthode

clean all connection
public cleanConnection ( )

close() public méthode

Close a connection.
public close ( integer $fd, integer $code = self::CLOSE_NORMAL, string $reason = '' ) : boolean
$fd integer
$code integer
$reason string Reason.
Résultat boolean

doHandshake() public méthode

Do the handshake.
public doHandshake ( Request $request, Response $response ) : boolean
$request Swoole\Request
$response Swoole\Response
Résultat boolean

newFrame() public méthode

Write a frame.
public newFrame ( string $message, integer $opcode = self::OPCODE_TEXT_FRAME, boolean $end = true ) : integer
$message string Message.
$opcode integer Opcode.
$end boolean
Résultat integer

onClose() public méthode

public onClose ( $serv, $client_id, $from_id )

onConnect() public méthode

public onConnect ( $serv, $fd, $from_id )

onEnter() public méthode

public onEnter ( $client_id )
$client_id

onExit() public méthode

客户端退出
public onExit ( $client_id ) : mixed
$client_id
Résultat mixed

onHttpRequest() public méthode

Produce response for Http request.
public onHttpRequest ( Request $request ) : Response
$request Swoole\Request
Résultat Swoole\Response

onMessage() abstract public méthode

收到消息
abstract public onMessage ( $client_id, $message ) : mixed
$client_id
$message
Résultat mixed

onReceive() public méthode

Read a frame.
public onReceive ( $server, $fd, $from_id, $data )

onRequest() public méthode

Request come
public onRequest ( Request $request ) : Response
$request Swoole\Request
Résultat Swoole\Response

onWebSocketRequest() public méthode

Produce response for WebSocket request.
public onWebSocketRequest ( Request $request ) : Response
$request Swoole\Request
Résultat Swoole\Response

onWsConnect() public méthode

Called on WebSocket connection established.
public onWsConnect ( $client_id, $request )
$client_id
$request

opcodeSwitch() public méthode

opcode switch
public opcodeSwitch ( $client_id, &$ws )
$client_id
$ws

parseFrame() public méthode

解析数据帧 返回false表示解析失败,需要关闭此连接
public parseFrame ( &$buffer ) : array | boolean
$buffer
Résultat array | boolean

parseMessage() protected méthode

protected parseMessage ( $ws )

send() public méthode

Send a message.
public send ( integer $client_id, string $message, integer $opcode = self::OPCODE_TEXT_FRAME, boolean $end = true ) : boolean
$client_id integer
$message string Message.
$opcode integer Opcode.
$end boolean Whether it is the last frame of the message.
Résultat boolean

Property Details

$connections public_oe property

public $connections

$frame_list public_oe property

public $frame_list

$heart_time public_oe property

数据包最大长度,超过此长度会被认为是非法请求
public $heart_time

$keepalive public_oe property

600s life time
public $keepalive

$max_connect public_oe property

public $max_connect

$max_frame_size public_oe property

public $max_frame_size