Book/swoole-Phpdoc专题

Swoole

目录

简介

类摘要

Swoole\Async

class Swoole\Async {

/* 方法 */

public <span class="modifier">static void <span class="methodname">dnsLookup ( <span class="type">string $hostname , <span class="methodparam">callable $callback )

public <span class="modifier">static bool <span class="methodname">read ( <span class="type">string $filename , <span class="methodparam">callable $callback [, <span class="type">int $chunk_size [, <span class="methodparam">int $offset ]] )

public <span class="modifier">static void <span class="methodname">readFile ( <span class="type">string $filename , <span class="methodparam">callable $callback )

public <span class="modifier">static void <span class="methodname">set ( <span class="type">array $settings )

public <span class="modifier">static void <span class="methodname">write ( <span class="type">string $filename , <span class="methodparam">string $content [, int $offset [, <span class="type">callable $callback ]] )

public <span class="modifier">static void <span class="methodname">writeFile ( <span class="type">string $filename , <span class="methodparam">string $content [, callable $callback [, <span class="type">string $flags ]] )

}

Swoole\Async::dnsLookup

Async and non-blocking hostname to IP lookup.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Async::dnsLookup ( <span class="methodparam">string $hostname , callable $callback )

Warning

本函数还未编写文档,仅有参数列表。

参数

hostname
The host name.

callback
mixed <span class="replaceable">callback ( <span class="methodparam">string $hostname , string $ip )

hostname
The host name.

IP
The IP address.

Swoole\Async::read

Read file stream asynchronously.

说明

public <span class="modifier">static bool <span class="methodname">Swoole\Async::read ( <span class="methodparam">string $filename , callable $callback [, <span class="type">int $chunk_size [, <span class="methodparam">int $offset ]] )

参数

filename
The name of the file.

callback
mixed <span class="replaceable">callback ( <span class="methodparam">string $filename , string $content )

filename
The name of the file.

content
The content readed from the file stream.

chunk_size
The chunk length.

offset
The offset.

返回值

Whether the read is succeed.

Swoole\Async::readFile

Read a file asynchronously.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Async::readFile ( <span class="methodparam">string $filename , callable $callback )

参数

filename
The filename of the file being read.

callback
mixed <span class="replaceable">callback ( <span class="methodparam">string $filename , string $content )

filename
The name of the file.

content
The content readed from the file.

Swoole\Async::set

Update the async I/O options.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Async::set ( <span class="methodparam">array $settings )

参数

settings

Swoole\Async::write

Write data to a file stream asynchronously.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Async::write ( <span class="methodparam">string $filename , string $content [, <span class="type">int $offset [, <span class="methodparam">callable $callback ]] )

参数

filename
The filename being written.

content
The content writing to the file.

offset
The offset.

callback

Swoole\Async::writeFile

Description

说明

public <span class="modifier">static void <span class="methodname">Swoole\Async::writeFile ( <span class="methodparam">string $filename , string $content [, <span class="type">callable $callback [, <span class="methodparam">string $flags ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

filename
The filename being written.

content
The content writing to the file.

callback

flags

简介

类摘要

Swoole\Atomic

class Swoole\Atomic {

/* 方法 */

public int <span class="methodname">add ([ <span class="type">int $add_value ] )

public int <span class="methodname">cmpset ( <span class="type">int $cmp_value , <span class="methodparam">int $new_value )

public int <span class="methodname">get ( void )

public int <span class="methodname">set ( <span class="type">int $value )

public int <span class="methodname">sub ([ <span class="type">int $sub_value ] )

}

Swoole\Atomic::add

Add a number to the value to the atomic object.

说明

public int <span class="methodname">Swoole\Atomic::add ([ <span class="methodparam">int $add_value ] )

Add a number to the value to the atomic object.

参数

add_value
The value which will be added to the current value.

返回值

The new value of the atomic object.

Swoole\Atomic::cmpset

Compare and set the value of the atomic object.

说明

public int <span class="methodname">Swoole\Atomic::cmpset ( <span class="methodparam">int $cmp_value , int $new_value )

参数

cmp_value
The value to compare with the current value of the atomic object.

new_value
The value to set to the atomic object if the cmp_value is the same as the current value of the atomic object.

返回值

The new value of the atomic object.

Swoole\Atomic::__construct

Construct a swoole atomic object.

说明

public <span class="methodname">Swoole\Atomic::__construct ([ <span class="methodparam">int $value ] )

Swoole atomic object is a integer variable allows any processor to atomically test and modify. It is implemented based on CPU atomic instructions. The Swoole atomic variables have to defined before swoole_server->start.

Compare-and-swap (CAS) is an atomic instruction used in multithreading to achieve synchronization. It compares the content of a memory location with a given value and, only if they are the same, modifies the content of that memory location to a new given value.

参数

value
The value of the atomic object.

Swoole\Atomic::get

Get the current value of the atomic object.

说明

public int <span class="methodname">Swoole\Atomic::get ( <span class="methodparam">void )

Get the current value of the atomic object.

参数

此函数没有参数。

返回值

The current value of the atomic object.

Swoole\Atomic::set

Set a new value to the atomic object.

说明

public int <span class="methodname">Swoole\Atomic::set ( <span class="methodparam">int $value )

Set a new value to the atomic object.

Warning

本函数还未编写文档,仅有参数列表。

参数

value
The value to set to the atomic object.

返回值

The current value of the atomic object.

Swoole\Atomic::sub

Subtract a number to the value of the atomic object.

说明

public int <span class="methodname">Swoole\Atomic::sub ([ <span class="methodparam">int $sub_value ] )

Subtract a number to the value of the atomic object.

参数

sub_value
The value which will be subtracted to the current value.

返回值

The current value of the atomic object.

简介

类摘要

Swoole\Buffer

class Swoole\Buffer {

/* 方法 */

public int <span class="methodname">append ( <span class="type">string $data )

public void clear ( <span class="methodparam">void )

public void __destruct ( <span class="methodparam">void )

public int <span class="methodname">expand ( <span class="type">int $size )

public string read ( <span class="type">int $offset , <span class="methodparam">int $length )

public void recycle ( <span class="methodparam">void )

public string substr ( <span class="type">int $offset [, <span class="methodparam">int $length [, bool $remove ]] )

public string __toString ( <span class="methodparam">void )

public void write ( <span class="type">int $offset , <span class="methodparam">string $data )

}

Swoole\Buffer::append

Append the string or binary data at the end of the memory buffer and return the new size of memory allocated.

说明

public int <span class="methodname">Swoole\Buffer::append ( <span class="methodparam">string $data )

参数

data
The string or binary data to append at the end of the memory buffer.

返回值

The new size of the memory buffer.

Swoole\Buffer::clear

Reset the memory buffer.

说明

public void Swoole\Buffer::clear ( <span class="methodparam">void )

参数

此函数没有参数。

Swoole\Buffer::__construct

Fixed size memory blocks allocation.

说明

public <span class="methodname">Swoole\Buffer::__construct ([ <span class="methodparam">int $size ] )

参数

size
The size of the memory to allocate.

Swoole\Buffer::__destruct

Destruct the Swoole memory buffer.

说明

public void Swoole\Buffer::__destruct ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

Swoole\Buffer::expand

Expand the size of memory buffer.

说明

public int <span class="methodname">Swoole\Buffer::expand ( <span class="methodparam">int $size )

参数

size
The new size of the memory buffer.

返回值

The new size of the memory buffer.

Swoole\Buffer::read

Read data from the memory buffer based on offset and length.

说明

public string Swoole\Buffer::read ( <span class="methodparam">int $offset , int $length )

参数

offset
The offset.

length
The length.

返回值

The data readed from the memory buffer.

Swoole\Buffer::recycle

Release the memory to OS which is not used by the memory buffer.

说明

public void Swoole\Buffer::recycle ( <span class="methodparam">void )

参数

此函数没有参数。

Swoole\Buffer::substr

Read data from the memory buffer based on offset and length. Or remove data from the memory buffer.

说明

public string Swoole\Buffer::substr ( <span class="methodparam">int $offset [, int $length [, bool $remove ]] )

If $remove is set to be true and $offset is set to be 0, the data will be removed from the buffer. The memory for storing the data will be released when the buffer object is deconstructed.

参数

offset
The offset.

length
The length.

remove
Whether to remove the data from the memory buffer.

返回值

The data or string readed from the memory buffer.

Swoole\Buffer::__toString

Get the string value of the memory buffer.

说明

public string Swoole\Buffer::__toString ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

The string value of the memory buffer.

Swoole\Buffer::write

Write data to the memory buffer. The memory allocated for the buffer will not be changed.

说明

public void Swoole\Buffer::write ( <span class="methodparam">int $offset , string $data )

参数

offset
The offset.

data
The data to write to the memory buffer.

返回值

简介

类摘要

Swoole\Channel

class Swoole\Channel {

/* 方法 */

public void __destruct ( <span class="methodparam">void )

public mixed pop ( <span class="methodparam">void )

public bool push ( <span class="type">string $data )

public array stats ( <span class="methodparam">void )

}

Swoole\Channel::__construct

Construct a Swoole Channel

说明

public <span class="methodname">Swoole\Channel::__construct ( <span class="methodparam">string $size )

Swoole channel is memory data structure works like Chan in Golang, implemented based on shared memory and mutex locks. It can be used as high performance message queue in memory. Construct a swoole channel with a fixed size. The minimum size of a swoole channel is 64KB. Exceptions will be thrown if there is not enough memory.

参数

size
The size of the Swoole channel.

Swoole\Channel::__destruct

Destruct a Swoole channel.

说明

public void Swoole\Channel::__destruct ( <span class="methodparam">void )

参数

此函数没有参数。

Swoole\Channel::pop

Read and pop data from swoole channel.

说明

public mixed Swoole\Channel::pop ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

If the channel is empty, the function will return false, or return the unserialized data.

Swoole\Channel::push

Write and push data into Swoole channel.

说明

public bool Swoole\Channel::push ( <span class="methodparam">string $data )

Data can be any non-empty PHP variable, the variable will be serialized if it is not string type.

If size of the data is more than 8KB, swoole channel will use temp files storage.

The function will return true if the write operation is succeeded, or return false if there is not enough space.

参数

data
The data to push into the Swoole channel.

返回值

Wheter the data is pushed into he Swoole channel.

Swoole\Channel::stats

Get stats of swoole channel.

说明

public array Swoole\Channel::stats ( <span class="methodparam">void )

Get the numbers of queued elements and total size of the memory used by the queue.

参数

此函数没有参数。

返回值

The stats of the Swoole channel.

简介

类摘要

Swoole\Client

class Swoole\Client {

/* Constants */

const int Swoole\Client::MSG_OOB = 1 ;

const int Swoole\Client::MSG_PEEK = 2 ;

const int Swoole\Client::MSG_DONTWAIT = 128 ;

const int Swoole\Client::MSG_WAITALL = 64 ;

/* 属性 */

public $errCode ;

public $sock ;

public $reuse ;

public $reuseCount ;

/* 方法 */

public bool close ([ <span class="methodparam">bool $force ] )

public bool connect ( <span class="methodparam">string $host [, int $port [, int $timeout [, <span class="type">int $flag ]]] )

public void __destruct ( <span class="methodparam">void )

public array getpeername ( <span class="methodparam">void )

public array getsockname ( <span class="methodparam">void )

public bool isConnected ( <span class="methodparam">void )

public void on ( <span class="type">string $event , <span class="methodparam">callable $callback )

public void pause ( <span class="methodparam">void )

public void pipe ( <span class="type">string $socket )

public void recv ([ <span class="type">string $size [, <span class="methodparam">string $flag ]] )

public void resume ( <span class="methodparam">void )

public int <span class="methodname">send ( <span class="type">string $data [, <span class="methodparam">string $flag ] )

public bool sendfile ( <span class="methodparam">string $filename [, int $offset ] )

public bool sendto ( <span class="type">string $ip , <span class="methodparam">int $port , <span class="methodparam">string $data )

public void set ( <span class="type">array $settings )

public void sleep ( <span class="methodparam">void )

public void wakeup ( <span class="methodparam">void )

}

属性

errCode

sock

reuse

reuseCount

预定义常量

Swoole\Client::MSG_OOB

Swoole\Client::MSG_PEEK

Swoole\Client::MSG_DONTWAIT

Swoole\Client::MSG_WAITALL

Swoole\Client::close

Close the connection established.

说明

public bool Swoole\Client::close ([ <span class="methodparam">bool $force ] )

参数

force
Whether force to close the connection.

返回值

Whether the connection is closed.

Swoole\Client::connect

Connect to the remote TCP or UDP port.

说明

public bool Swoole\Client::connect ( <span class="methodparam">string $host [, int $port [, int $timeout [, <span class="type">int $flag ]]] )

参数

host
The host name of the remote address.

port
The port number of the remote address.

timeout
The timeout(second) of connect/send/recv, the dafault value is 0.1s

flag
If the type of client is UDP, the $flag means if to enable the configuration udp_connect. If the configuration udp_connect is enabled, the client will only receive the data from specified ip:port. If the type of client is TCP and the $flag is set to 1, it must use swoole_client_select to check the connection status before send/recv.

返回值

Whether the connection is established.

Swoole\Client::__construct

Create Swoole sync or async TCP/UDP client, with or without SSL.

说明

public <span class="methodname">Swoole\Client::__construct ( <span class="methodparam">int $sock_type [, int $is_async ] )

参数

sock_type
The type of socket: SWOOLE_TCP, SWOOLE_UDP, SWOOLE_ASYNC, SWOOLE_SSL, SWOOLE_KEEP.

is_async
Synchronous or asynchronous client.

Swoole\Client::__destruct

Destruct the Swoole client.

说明

public void Swoole\Client::__destruct ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

Swoole\Client::getpeername

Get the remote socket name of the connection.

说明

public array Swoole\Client::getpeername ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

The host and port of the remote socket.

Swoole\Client::getsockname

Get the local socket name of the connection.

说明

public array Swoole\Client::getsockname ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

The host and port of the local socket.

Swoole\Client::isConnected

Check if the connection is established.

说明

public bool Swoole\Client::isConnected ( <span class="methodparam">void )

This method returns the connection status of application layer.

参数

此函数没有参数。

返回值

Whether the connection is established.

Swoole\Client::on

Add callback functions triggered by events.

说明

public void Swoole\Client::on ( <span class="methodparam">string $event , callable $callback )

参数

event

callback

Swoole\Client::pause

Pause receiving data.

说明

public void Swoole\Client::pause ( <span class="methodparam">void )

参数

此函数没有参数。

Swoole\Client::pipe

Redirect the data to another file descriptor.

说明

public void Swoole\Client::pipe ( <span class="methodparam">string $socket )

参数

socket

Swoole\Client::recv

Receive data from the remote socket.

说明

public void Swoole\Client::recv ([ <span class="methodparam">string $size [, string $flag ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

size

flag

返回值

Swoole\Client::resume

Resume receiving data.

说明

public void Swoole\Client::resume ( <span class="methodparam">void )

参数

此函数没有参数。

Swoole\Client::send

Send data to the remote TCP socket.

说明

public int <span class="methodname">Swoole\Client::send ( <span class="methodparam">string $data [, string $flag ] )

参数

data
The data to send which can be string or binary

flag

返回值

If the client sends data successfully, it returns the length of data sent. Or it returns false and sets $swoole_client->errCode. For sync client, there is no limit for the data to send. For async client, The limit for the data to send is socket_buffer_size.

Swoole\Client::sendfile

Send file to the remote TCP socket.

说明

public bool Swoole\Client::sendfile ( <span class="methodparam">string $filename [, int $offset ] )

This is a wrapper of the Linux sendfile system call.

参数

filename
File path of the file to send.

offset
Offset of the file to send

返回值

Swoole\Client::sendto

Send data to the remote UDP address.

说明

public bool Swoole\Client::sendto ( <span class="methodparam">string $ip , int $port , string $data )

The swoole client should be type of SWOOLE_SOCK_UDP or SWOOLE_SOCK_UDP6.

参数

ip
The IP address of remote host, IPv4 or IPv6.

port
The port number of remote host.

data
The data to send which should be less-than 64K.

返回值

Swoole\Client::set

Set the Swoole client parameters before the connection is established.

说明

public void Swoole\Client::set ( <span class="methodparam">array $settings )

参数

settings

返回值

Swoole\Client::sleep

Remove the TCP client from system event loop.

说明

public void Swoole\Client::sleep ( <span class="methodparam">void )

Remove the TCP client from system event loop.

参数

此函数没有参数。

返回值

Swoole\Client::wakeup

Add the TCP client back into the system event loop.

说明

public void Swoole\Client::wakeup ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Connection\Iterator

class Swoole\Connection\Iterator implements <span class="interfacename">Iterator <span class="oointerface">, Countable , <span class="interfacename">ArrayAccess {

/* 方法 */

public int <span class="methodname">count ( void )

public <span class="type">Connection current ( void )

public int <span class="methodname">key ( void )

public <span class="type">Connection next ( void )

public bool offsetExists ( <span class="methodparam">int $index )

public <span class="type">Connection offsetGet ( string $index )

public void offsetSet ( <span class="methodparam">int $offset , mixed $connection )

public void offsetUnset ( <span class="methodparam">int $offset )

public void rewind ( <span class="methodparam">void )

public bool valid ( <span class="methodparam">void )

}

Swoole\Connection\Iterator::count

Count connections.

说明

public int <span class="methodname">Swoole\Connection\Iterator::count ( <span class="methodparam">void )

Gets the number of connections.

参数

此函数没有参数。

返回值

The number of connections.

Swoole\Connection\Iterator::current

Return current connection entry.

说明

public <span class="type">Connection <span class="methodname">Swoole\Connection\Iterator::current ( <span class="methodparam">void )

Get current connection entry.

参数

此函数没有参数。

返回值

The current connection entry.

Swoole\Connection\Iterator::key

Return key of the current connection.

说明

public int <span class="methodname">Swoole\Connection\Iterator::key ( <span class="methodparam">void )

This function returns key of the current connection.

参数

此函数没有参数。

返回值

Key of the current connection.

Swoole\Connection\Iterator::next

Move to the next connection.

说明

public <span class="type">Connection <span class="methodname">Swoole\Connection\Iterator::next ( <span class="methodparam">void )

The iterator to the next connection.

参数

此函数没有参数。

返回值

Swoole\Connection\Iterator::offsetExists

Check if offet exists.

说明

public bool <span class="methodname">Swoole\Connection\Iterator::offsetExists ( int $index )

Check if offset exists.

参数

index
The offset being checked.

返回值

Returns TRUE if the offset exists, otherwise FALSE.

Swoole\Connection\Iterator::offsetGet

Offset to retrieve.

说明

public <span class="type">Connection <span class="methodname">Swoole\Connection\Iterator::offsetGet ( string $index )

Return the connection at specified offset.

参数

index
The offset to retrieve.

返回值

Swoole\Connection\Iterator::offsetSet

Assign a Connection to the specified offset.

说明

public void Swoole\Connection\Iterator::offsetSet ( int $offset , <span class="type">mixed $connection )

Assign a Connection to the specified offset.

参数

offset
The offset to assign the Connection to.

connection
The connection to set.

返回值

Swoole\Connection\Iterator::offsetUnset

Unset an offset.

说明

public void <span class="methodname">Swoole\Connection\Iterator::offsetUnset ( int $offset )

Unsets an offset.

参数

offset
The offset to unset.

返回值

Swoole\Connection\Iterator::rewind

Rewinds iterator

说明

public void Swoole\Connection\Iterator::rewind ( void )

参数

此函数没有参数。

返回值

Swoole\Connection\Iterator::valid

Check if current position is valid.

说明

public bool Swoole\Connection\Iterator::valid ( void )

Checks if the current position is valid.

参数

此函数没有参数。

返回值

Returns TRUE if the current iterator position is valid, otherwise FALSE.

简介

类摘要

Swoole\Coroutine

class Swoole\Coroutine {

/* 方法 */

public <span class="modifier">static mixed <span class="methodname">call_user_func_array ( <span class="methodparam">callable $callback , <span class="type">array $param_array )

public <span class="modifier">static mixed <span class="methodname">call_user_func ( <span class="methodparam">callable $callback , <span class="type">mixed $args )

public <span class="modifier">static ReturnType cli_wait ( <span class="methodparam">void )

public <span class="modifier">static ReturnType create ( <span class="methodparam">void )

public <span class="modifier">static ReturnType getuid ( <span class="methodparam">void )

public <span class="modifier">static ReturnType resume ( <span class="methodparam">void )

public <span class="modifier">static ReturnType suspend ( <span class="methodparam">void )

}

Swoole\Coroutine::call_user_func_array

Call a callback with an array of parameters

说明

public <span class="modifier">static mixed <span class="methodname">Swoole\Coroutine::call_user_func_array ( callable $callback , <span class="type">array $param_array )

Calls the callback given by the first parameter with the parameters in param_array.

参数

callback
The callable to be called.

param_array
Zero or more parameters in the array to be passed to the callback.

返回值

Swoole\Coroutine::call_user_func

Call a callback given by the first parameter

说明

public <span class="modifier">static mixed <span class="methodname">Swoole\Coroutine::call_user_func ( <span class="methodparam">callable $callback , <span class="type">mixed $args )

Calls the callback given by the first parameter and passes the remaining parameters as arguments.

参数

callback
The callable to be called.

args
Zero or more parameters to be passed to the callback.

返回值

Swoole\Coroutine::cli_wait

Description

说明

public <span class="modifier">static ReturnType Swoole\Coroutine::cli_wait ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Coroutine::create

Description

说明

public <span class="modifier">static ReturnType Swoole\Coroutine::create ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Coroutine::getuid

Description

说明

public <span class="modifier">static ReturnType Swoole\Coroutine::getuid ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Coroutine::resume

Description

说明

public <span class="modifier">static ReturnType Swoole\Coroutine::resume ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Coroutine::suspend

Description

说明

public <span class="modifier">static ReturnType Swoole\Coroutine::suspend ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Event

class Swoole\Event {

/* 方法 */

public <span class="modifier">static bool <span class="methodname">add ( <span class="type">int $fd , <span class="type">callable $read_callback [, <span class="methodparam">callable $write_callback [, <span class="type">string $events ]] )

public <span class="modifier">static void <span class="methodname">defer ( <span class="type">mixed $callback )

public <span class="modifier">static bool <span class="methodname">del ( <span class="type">string $fd )

public <span class="modifier">static void <span class="methodname">exit ( void )

public <span class="modifier">static bool <span class="methodname">set ( <span class="type">int $fd [, <span class="type">string $read_callback [, <span class="methodparam">string $write_callback [, <span class="type">string $events ]]] )

public <span class="modifier">static void <span class="methodname">wait ( void )

public <span class="modifier">static void <span class="methodname">write ( <span class="type">string $fd , <span class="methodparam">string $data )

}

Swoole\Event::add

Add new callback functions of a socket into the EventLoop.

说明

public <span class="modifier">static bool <span class="methodname">Swoole\Event::add ( <span class="methodparam">int $fd , <span class="methodparam">callable $read_callback [, <span class="type">callable $write_callback [, <span class="methodparam">string $events ]] )

参数

fd

read_callback

write_callback

events

返回值

Swoole\Event::defer

Add a callback function to the next event loop.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Event::defer ( <span class="methodparam">mixed $callback )

参数

callback

返回值

Swoole\Event::del

Remove all event callback functions of a socket.

说明

public <span class="modifier">static bool <span class="methodname">Swoole\Event::del ( <span class="methodparam">string $fd )

参数

fd

返回值

Swoole\Event::exit

Exit the eventloop, only available at client side.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Event::exit ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Event::set

Update the event callback functions of a socket.

说明

public <span class="modifier">static bool <span class="methodname">Swoole\Event::set ( <span class="methodparam">int $fd [, <span class="methodparam">string $read_callback [, <span class="type">string $write_callback [, <span class="methodparam">string $events ]]] )

参数

fd

read_callback

write_callback

events

返回值

Swoole\Event::wait

Description

说明

public <span class="modifier">static void <span class="methodname">Swoole\Event::wait ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Event::write

Write data to the socket.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Event::write ( <span class="methodparam">string $fd , string $data )

参数

fd

data

返回值

简介

类摘要

Swoole\Exception

class Swoole\Exception <span class="ooclass"> extends Exception implements <span class="interfacename">Throwable {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

}

简介

类摘要

Swoole\Http\Client

class Swoole\Http\Client {

/* 属性 */

public $errCode ;

public $sock ;

/* 方法 */

public void addFile ( <span class="methodparam">string $path , string $name [, <span class="type">string $type [, <span class="methodparam">string $filename [, string $offset ]]] )

public void close ( <span class="methodparam">void )

public void __destruct ( <span class="methodparam">void )

public void download ( <span class="methodparam">string $path , string $file , <span class="type">callable $callback [, <span class="methodparam">int $offset ] )

public void execute ( <span class="methodparam">string $path , string $callback )

public void get ( <span class="type">string $path , <span class="methodparam">callable $callback )

public bool isConnected ( <span class="methodparam">void )

public void on ( <span class="type">string $event_name , <span class="methodparam">callable $callback )

public void post ( <span class="type">string $path , <span class="methodparam">string $data , callable $callback )

public void push ( <span class="type">string $data [, <span class="methodparam">string $opcode [, string $finish ]] )

public void set ( <span class="type">array $settings )

public void setCookies ( <span class="methodparam">array $cookies )

public <span class="type">ReturnType setData ( string $data )

public void setHeaders ( <span class="methodparam">array $headers )

public void setMethod ( <span class="methodparam">string $method )

public void upgrade ( <span class="methodparam">string $path , string $callback )

}

属性

errCode

sock

Swoole\Http\Client::addFile

Add a file to the post form.

说明

public void Swoole\Http\Client::addFile ( <span class="methodparam">string $path , string $name [, <span class="type">string $type [, <span class="methodparam">string $filename [, string $offset ]]] )

参数

path

name

type

filename

offset

返回值

Swoole\Http\Client::close

Close the http connection.

说明

public void Swoole\Http\Client::close ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Http\Client::__construct

Construct the async HTTP client.

说明

public <span class="methodname">Swoole\Http\Client::__construct ( <span class="methodparam">string $host [, string $port [, <span class="type">bool $ssl ]] )

参数

host
The hostname of the remote host.

port
The port number of the remote host.

ssl
Whether to enable SSL.

Swoole\Http\Client::__destruct

Destruct the HTTP client.

说明

public void Swoole\Http\Client::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Client::download

Download a file from the remote server.

说明

public void Swoole\Http\Client::download ( <span class="methodparam">string $path , string $file , <span class="type">callable $callback [, <span class="methodparam">int $offset ] )

参数

path

file

callback

offset

返回值

Swoole\Http\Client::execute

Send the HTTP request after setting the parameters.

说明

public void Swoole\Http\Client::execute ( <span class="methodparam">string $path , string $callback )

参数

path

callback

返回值

Swoole\Http\Client::get

Send GET http request to the remote server.

说明

public void Swoole\Http\Client::get ( <span class="methodparam">string $path , callable $callback )

参数

path

callback

返回值

Swoole\Http\Client::isConnected

Check if the HTTP connection is connected.

说明

public bool Swoole\Http\Client::isConnected ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Client::on

Register callback function by event name.

说明

public void Swoole\Http\Client::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

参数

event_name

callback

返回值

Swoole\Http\Client::post

Send POST http request to the remote server.

说明

public void Swoole\Http\Client::post ( <span class="methodparam">string $path , string $data , <span class="type">callable $callback )

参数

path

data

callback

返回值

Swoole\Http\Client::push

Push data to websocket client.

说明

public void Swoole\Http\Client::push ( <span class="methodparam">string $data [, string $opcode [, <span class="type">string $finish ]] )

参数

data

opcode

finish

返回值

Swoole\Http\Client::set

Update the HTTP client paramters.

说明

public void Swoole\Http\Client::set ( <span class="methodparam">array $settings )

参数

settings

返回值

Swoole\Http\Client::setCookies

Set the http request cookies.

说明

public void Swoole\Http\Client::setCookies ( <span class="methodparam">array $cookies )

参数

cookies

返回值

Swoole\Http\Client::setData

Set the HTTP request body data.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Http\Client::setData ( <span class="methodparam">string $data )

The HTTP method will be changed to be POST.

参数

data

返回值

Swoole\Http\Client::setHeaders

Set the HTTP request headers.

说明

public void Swoole\Http\Client::setHeaders ( <span class="methodparam">array $headers )

参数

headers

返回值

Swoole\Http\Client::setMethod

Set the HTTP request method.

说明

public void Swoole\Http\Client::setMethod ( <span class="methodparam">string $method )

参数

method

返回值

Swoole\Http\Client::upgrade

Upgrade to websocket protocol.

说明

public void Swoole\Http\Client::upgrade ( <span class="methodparam">string $path , string $callback )

参数

path

callback

返回值

简介

类摘要

Swoole\Http\Request

class Swoole\Http\Request {

/* 方法 */

public void __destruct ( <span class="methodparam">void )

public string rawcontent ( <span class="methodparam">void )

}

Swoole\Http\Request::__destruct

Destruct the HTTP request.

说明

public void Swoole\Http\Request::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Request::rawcontent

Get the raw HTTP POST body.

说明

public string Swoole\Http\Request::rawcontent ( void )

This method is used for the POST data which isn't in the form of `application/x-www-form-urlencoded`.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Http\Response

class Swoole\Http\Response {

/* 方法 */

public string cookie ( <span class="type">string $name [, <span class="methodparam">string $value [, string $expires [, <span class="type">string $path [, <span class="methodparam">string $domain [, string $secure [, <span class="type">string $httponly ]]]]]] )

public void __destruct ( <span class="methodparam">void )

public void end ([ <span class="type">string $content ] )

public <span class="type">ReturnType gzip ([ string $compress_level ] )

public void header ( <span class="type">string $key , <span class="methodparam">string $value [, string $ucwords ] )

public <span class="type">ReturnType <span class="methodname">initHeader ( <span class="methodparam">void )

public <span class="type">ReturnType rawcookie ( string $name [, <span class="type">string $value [, <span class="methodparam">string $expires [, string $path [, <span class="type">string $domain [, <span class="methodparam">string $secure [, string $httponly ]]]]]] )

public <span class="type">ReturnType sendfile ( string $filename [, <span class="type">int $offset ] )

public <span class="type">ReturnType status ( string $http_code )

public void write ( <span class="type">string $content )

}

Swoole\Http\Response::cookie

Set the cookies of the HTTP response.

说明

public string Swoole\Http\Response::cookie ( <span class="methodparam">string $name [, string $value [, <span class="type">string $expires [, <span class="methodparam">string $path [, string $domain [, <span class="type">string $secure [, <span class="methodparam">string $httponly ]]]]]] )

参数

name

value

expires

path

domain

secure

httponly

返回值

Swoole\Http\Response::__destruct

Destruct the HTTP response.

说明

public void Swoole\Http\Response::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Response::end

Send data for the HTTP request and finish the response.

说明

public void Swoole\Http\Response::end ([ <span class="methodparam">string $content ] )

参数

content

返回值

Swoole\Http\Response::gzip

Enable the gzip of response content.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Http\Response::gzip ([ <span class="methodparam">string $compress_level ] )

The header about Content-Encoding will be added automatically.

参数

compress_level

返回值

Swoole\Http\Response::header

Set the HTTP response headers.

说明

public void Swoole\Http\Response::header ( <span class="methodparam">string $key , string $value [, <span class="type">string $ucwords ] )

参数

key

value

ucwords

返回值

Swoole\Http\Response::initHeader

Init the HTTP response header.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Http\Response::initHeader ( <span class="methodparam">void )

Init the HTTP response header.

参数

此函数没有参数。

返回值

Swoole\Http\Response::rawcookie

Set the raw cookies to the HTTP response.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Http\Response::rawcookie ( <span class="methodparam">string $name [, string $value [, <span class="type">string $expires [, <span class="methodparam">string $path [, string $domain [, <span class="type">string $secure [, <span class="methodparam">string $httponly ]]]]]] )

参数

name

value

expires

path

domain

secure

httponly

返回值

Swoole\Http\Response::sendfile

Send file through the HTTP response.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Http\Response::sendfile ( <span class="methodparam">string $filename [, int $offset ] )

Send file through the HTTP response.

参数

filename

offset

返回值

Swoole\Http\Response::status

Set the status code of the HTTP response.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Http\Response::status ( <span class="methodparam">string $http_code )

Set the status code of the HTTP response.

参数

http_code

返回值

Swoole\Http\Response::write

Append HTTP body content to the HTTP response.

说明

public void Swoole\Http\Response::write ( <span class="methodparam">string $content )

Append HTTP body content to the HTTP response.

参数

content

返回值

简介

类摘要

Swoole\Http\Server

class Swoole\Http\Server <span class="ooclass"> extends Swoole\Server {

/* 方法 */

public void on ( <span class="type">string $event_name , <span class="methodparam">callable $callback )

public void start ( <span class="methodparam">void )

/* 继承的方法 */

public void Swoole\Server::addlistener ( <span class="methodparam">string $host , int $port , string $socket_type )

public bool Swoole\Server::addProcess ( <span class="methodparam">swoole_process $process )

public <span class="type">ReturnType <span class="methodname">Swoole\Server::after ( <span class="methodparam">int $after_time_ms , <span class="type">callable $callback [, <span class="methodparam">string $param ] )

public bool Swoole\Server::bind ( <span class="methodparam">int $fd , <span class="methodparam">int $uid )

public void Swoole\Server::clearTimer ( <span class="methodparam">int $timer_id )

void <span class="methodname">swoole_timer_clear ( <span class="methodparam">int $timer_id )

public bool Swoole\Server::close ( <span class="methodparam">int $fd [, <span class="methodparam">bool $reset ] )

public bool Swoole\Server::confirm ( <span class="methodparam">int $fd )

public array Swoole\Server::connection_info ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

public array Swoole\Server::connection_list ( <span class="methodparam">int $start_fd [, int $pagesize ] )

public void Swoole\Server::defer ( <span class="methodparam">callable $callback )

public bool Swoole\Server::exist ( <span class="methodparam">int $fd )

public void Swoole\Server::finish ( <span class="methodparam">string $data )

public <span class="type">ReturnType <span class="methodname">Swoole\Server::getClientInfo ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

public array Swoole\Server::getClientList ( <span class="methodparam">int $start_fd [, int $pagesize ] )

public int <span class="methodname">Swoole\Server::getLastError ( <span class="methodparam">void )

public mixed Swoole\Server::heartbeat ( <span class="methodparam">bool $if_close_connection )

public bool Swoole\Server::listen ( <span class="methodparam">string $host , int $port , string $socket_type )

public void Swoole\Server::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

public void Swoole\Server::pause ( <span class="methodparam">int $fd )

public void Swoole\Server::protect ( <span class="methodparam">int $fd [, <span class="methodparam">bool $is_protected ] )

public bool Swoole\Server::reload ( <span class="methodparam">void )

public void Swoole\Server::resume ( <span class="methodparam">int $fd )

public bool Swoole\Server::send ( <span class="methodparam">int $fd , <span class="methodparam">string $data [, int $reactor_id ] )

public bool Swoole\Server::sendfile ( <span class="methodparam">int $fd , <span class="methodparam">string $filename [, int $offset ] )

public bool Swoole\Server::sendMessage ( <span class="methodparam">int $worker_id , string $data )

public bool Swoole\Server::sendto ( <span class="methodparam">string $ip , int $port , string $data [, <span class="type">string $server_socket ] )

public bool Swoole\Server::sendwait ( <span class="methodparam">int $fd , <span class="methodparam">string $data )

public <span class="type">ReturnType <span class="methodname">Swoole\Server::set ( <span class="methodparam">array $settings )

public void Swoole\Server::shutdown ( <span class="methodparam">void )

public void Swoole\Server::start ( <span class="methodparam">void )

public array Swoole\Server::stats ( <span class="methodparam">void )

public bool Swoole\Server::stop ([ <span class="methodparam">int $worker_id ] )

public mixed Swoole\Server::task ( <span class="methodparam">string $data [, int $dst_worker_id [, <span class="type">callable $callback ]] )

public void Swoole\Server::taskwait ( <span class="methodparam">string $data [, float $timeout [, <span class="type">int $worker_id ]] )

public void Swoole\Server::taskWaitMulti ( <span class="methodparam">array $tasks [, double $timeout_ms ] )

public void Swoole\Server::tick ( <span class="methodparam">int $interval_ms , callable $callback )

}

Swoole\Http\Server::on

Bind callback function to HTTP server by event name.

说明

public void Swoole\Http\Server::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

Bind callback function to HTTP server by event name.

参数

event_name

callback

返回值

Swoole\Http\Server::start

Start the swoole http server.

说明

public void Swoole\Http\Server::start ( <span class="methodparam">void )

Start the swoole http server.

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Lock

class Swoole\Lock {

/* 方法 */

public void __destruct ( <span class="methodparam">void )

public void lock_read ( <span class="methodparam">void )

public void lock ( <span class="methodparam">void )

public void trylock_read ( <span class="methodparam">void )

public void trylock ( <span class="methodparam">void )

public void unlock ( <span class="methodparam">void )

}

Swoole\Lock::__construct

Construct a memory lock.

说明

public <span class="methodname">Swoole\Lock::__construct ([ <span class="methodparam">string $type [, string $file_lock_location ]] )

Swoole lock is used for data synchronization between multiple theads or processes.

参数

type

file_lock_location

Swoole\Lock::__destruct

Destory a Swoole memory lock.

说明

public void Swoole\Lock::__destruct ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Lock::lock_read

Lock a read-write lock for reading.

说明

public void Swoole\Lock::lock_read ( <span class="methodparam">void )

Lock a read-write lock for reading.

参数

此函数没有参数。

返回值

Swoole\Lock::lock

Try to acquire the lock. It will block if the lock is not available.

说明

public void Swoole\Lock::lock ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Lock::trylock_read

Try to lock a read-write lock for reading and return straight away even the lock is not available.

说明

public void Swoole\Lock::trylock_read ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Lock::trylock

Try to acquire the lock and return straight away even the lock is not available.

说明

public void Swoole\Lock::trylock ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Lock::unlock

Release the lock.

说明

public void Swoole\Lock::unlock ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Mmap

class Swoole\Mmap {

/* 方法 */

public <span class="modifier">static ReturnType open ( <span class="type">string $filename [, <span class="methodparam">string $size [, string $offset ]] )

}

Swoole\Mmap::open

Map a file into memory and return the stream resource which can be used by PHP stream operations.

说明

public <span class="modifier">static ReturnType Swoole\Mmap::open ( <span class="methodparam">string $filename [, string $size [, <span class="type">string $offset ]] )

参数

filename

size

offset

返回值

简介

类摘要

Swoole\MySQL

class Swoole\MySQL {

/* 方法 */

public void close ( <span class="methodparam">void )

public void connect ( <span class="methodparam">array $server_config , <span class="type">callable $callback )

public void __destruct ( <span class="methodparam">void )

public <span class="type">ReturnType getBuffer ( void )

public void on ( <span class="type">string $event_name , <span class="methodparam">callable $callback )

public <span class="type">ReturnType query ( string $sql , callable $callback )

}

Swoole\MySQL::close

Close the async MySQL connection.

说明

public void Swoole\MySQL::close ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\MySQL::connect

Connect to the remote MySQL server.

说明

public void Swoole\MySQL::connect ( <span class="methodparam">array $server_config , <span class="type">callable $callback )

Connect to the remote MySQL server.

参数

server_config

callback

返回值

Swoole\MySQL::__construct

Construct an async MySQL client.

说明

public <span class="methodname">Swoole\MySQL::__construct ( <span class="methodparam">void )

Construct an async MySQL client.

参数

此函数没有参数。

Swoole\MySQL::__destruct

Destory the async MySQL client.

说明

public void Swoole\MySQL::__destruct ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\MySQL::getBuffer

Description

说明

public <span class="type">ReturnType <span class="methodname">Swoole\MySQL::getBuffer ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\MySQL::on

Register callback function based on event name.

说明

public void Swoole\MySQL::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

Register callback function based on event name, current only 'close' event is supported.

参数

event_name

callback

返回值

Swoole\MySQL::query

Run the SQL query.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\MySQL::query ( <span class="methodparam">string $sql , callable $callback )

参数

sql

callback

返回值

简介

类摘要

Swoole\MySQL\Exception

class Swoole\MySQL\Exception <span class="ooclass"> extends Exception implements <span class="interfacename">Throwable {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

}

简介

类摘要

Swoole\Process

class Swoole\Process {

/* Constants */

const int Swoole\Process::IPC_NOWAIT = 256 ;

/* 方法 */

public <span class="modifier">static void <span class="methodname">alarm ( <span class="type">int $interval_usec )

public void close ( <span class="methodparam">void )

public <span class="modifier">static void <span class="methodname">daemon ([ <span class="type">bool $nochdir [, <span class="methodparam">bool $noclose ]] )

public void __destruct ( <span class="methodparam">void )

public <span class="type">ReturnType exec ( string $exec_file , <span class="type">string $args )

public void exit ([ <span class="type">string $exit_code ] )

public void freeQueue ( <span class="methodparam">void )

public <span class="modifier">static void <span class="methodname">kill ( <span class="type">int $pid [, <span class="methodparam">string $signal_no ] )

public void name ( <span class="type">string $process_name )

public mixed pop ([ <span class="type">int $maxsize ] )

public bool push ( <span class="type">string $data )

public string read ([ <span class="type">int $maxsize ] )

public <span class="modifier">static void <span class="methodname">signal ( <span class="type">string $signal_no , <span class="methodparam">callable $callback )

public void start ( <span class="methodparam">void )

public array statQueue ( <span class="methodparam">void )

public bool useQueue ( <span class="methodparam">int $key [, int $mode ] )

public <span class="modifier">static array <span class="methodname">wait ([ <span class="type">bool $blocking ] )

public int <span class="methodname">write ( <span class="type">string $data )

}

预定义常量

Swoole\Process::IPC_NOWAIT

Swoole\Process::alarm

High precision timer which triggers signal with fixed interval.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Process::alarm ( <span class="methodparam">int $interval_usec )

参数

interval_usec

返回值

Swoole\Process::close

Close the pipe to the child process.

说明

public void Swoole\Process::close ( <span class="methodparam">void )

Close the pipe to the child process.

参数

此函数没有参数。

返回值

Swoole\Process::__construct

Construct a process.

说明

public <span class="methodname">Swoole\Process::__construct ( <span class="methodparam">callable $callback [, <span class="type">bool $redirect_stdin_and_stdout [, <span class="methodparam">int $pipe_type ]] )

参数

callback

redirect_stdin_and_stdout

pipe_type

Swoole\Process::daemon

Change the process to be a daemon process.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Process::daemon ([ <span class="methodparam">bool $nochdir [, bool $noclose ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

nochdir

noclose

返回值

Swoole\Process::__destruct

Destory the process.

说明

public void Swoole\Process::__destruct ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Process::exec

Execute system commands.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Process::exec ( <span class="methodparam">string $exec_file , string $args )

The process will be replaced to be the system command process, but the pipe to the parent process will be kept.

参数

exec_file

args

返回值

Swoole\Process::exit

Stop the child processes.

说明

public void Swoole\Process::exit ([ <span class="methodparam">string $exit_code ] )

参数

exit_code

返回值

Swoole\Process::freeQueue

Destroy the message queue created by swoole_process::useQueue.

说明

public void Swoole\Process::freeQueue ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Process::kill

Send signal to the child process.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Process::kill ( <span class="methodparam">int $pid [, string $signal_no ] )

Send signal to the child process.

参数

pid

signal_no

返回值

Swoole\Process::name

Set name of the process.

说明

public void Swoole\Process::name ( <span class="methodparam">string $process_name )

参数

process_name

返回值

Swoole\Process::pop

Read and pop data from the message queue.

说明

public mixed Swoole\Process::pop ([ <span class="methodparam">int $maxsize ] )

参数

maxsize

返回值

Swoole\Process::push

Write and push data into the message queue.

说明

public bool Swoole\Process::push ( <span class="methodparam">string $data )

参数

data

返回值

Swoole\Process::read

Read data sending to the process.

说明

public string Swoole\Process::read ([ <span class="methodparam">int $maxsize ] )

参数

maxsize

返回值

Swoole\Process::signal

Send signal to the child processes.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Process::signal ( <span class="methodparam">string $signal_no , callable $callback )

参数

signal_no

callback

返回值

If signal sent successfully, it returns TRUE, otherwise it returns FALSE.

Swoole\Process::start

Start the process.

说明

public void Swoole\Process::start ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Process::statQueue

Get the stats of the message queue used as the communication method between processes.

说明

public array Swoole\Process::statQueue ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

The array of status of the message queue.

Swoole\Process::useQueue

Create a message queue as the communication method between the parent process and child processes.

说明

public bool Swoole\Process::useQueue ( <span class="methodparam">int $key [, int $mode ] )

参数

key

mode

返回值

Swoole\Process::wait

Wait for the events of child processes.

说明

public <span class="modifier">static array <span class="methodname">Swoole\Process::wait ([ <span class="methodparam">bool $blocking ] )

参数

blocking

返回值

Swoole\Process::write

Write data into the pipe and communicate with the parent process or child processes.

说明

public int <span class="methodname">Swoole\Process::write ( <span class="methodparam">string $data )

参数

data

返回值

简介

类摘要

Swoole\Redis\Server

class Swoole\Redis\Server <span class="ooclass"> extends Swoole\Server {

/* Constants */

const int Swoole\Redis\Server::NIL = 1 ;

const int Swoole\Redis\Server::ERROR = 0 ;

const int Swoole\Redis\Server::STATUS = 2 ;

const int Swoole\Redis\Server::INT = 3 ;

const int Swoole\Redis\Server::STRING = 4 ;

const int Swoole\Redis\Server::SET = 5 ;

const int Swoole\Redis\Server::MAP = 6 ;

/* 方法 */

public <span class="modifier">static ReturnType format ( <span class="type">string $type [, <span class="methodparam">string $value ] )

public <span class="type">ReturnType <span class="methodname">setHandler ( <span class="type">string $command , <span class="methodparam">string $callback [, string $number_of_string_param [, <span class="type">string $type_of_array_param ]] )

public <span class="type">ReturnType start ( void )

/* 继承的方法 */

public void Swoole\Server::addlistener ( <span class="methodparam">string $host , int $port , string $socket_type )

public bool Swoole\Server::addProcess ( <span class="methodparam">swoole_process $process )

public <span class="type">ReturnType <span class="methodname">Swoole\Server::after ( <span class="methodparam">int $after_time_ms , <span class="type">callable $callback [, <span class="methodparam">string $param ] )

public bool Swoole\Server::bind ( <span class="methodparam">int $fd , <span class="methodparam">int $uid )

public void Swoole\Server::clearTimer ( <span class="methodparam">int $timer_id )

void <span class="methodname">swoole_timer_clear ( <span class="methodparam">int $timer_id )

public bool Swoole\Server::close ( <span class="methodparam">int $fd [, <span class="methodparam">bool $reset ] )

public bool Swoole\Server::confirm ( <span class="methodparam">int $fd )

public array Swoole\Server::connection_info ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

public array Swoole\Server::connection_list ( <span class="methodparam">int $start_fd [, int $pagesize ] )

public void Swoole\Server::defer ( <span class="methodparam">callable $callback )

public bool Swoole\Server::exist ( <span class="methodparam">int $fd )

public void Swoole\Server::finish ( <span class="methodparam">string $data )

public <span class="type">ReturnType <span class="methodname">Swoole\Server::getClientInfo ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

public array Swoole\Server::getClientList ( <span class="methodparam">int $start_fd [, int $pagesize ] )

public int <span class="methodname">Swoole\Server::getLastError ( <span class="methodparam">void )

public mixed Swoole\Server::heartbeat ( <span class="methodparam">bool $if_close_connection )

public bool Swoole\Server::listen ( <span class="methodparam">string $host , int $port , string $socket_type )

public void Swoole\Server::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

public void Swoole\Server::pause ( <span class="methodparam">int $fd )

public void Swoole\Server::protect ( <span class="methodparam">int $fd [, <span class="methodparam">bool $is_protected ] )

public bool Swoole\Server::reload ( <span class="methodparam">void )

public void Swoole\Server::resume ( <span class="methodparam">int $fd )

public bool Swoole\Server::send ( <span class="methodparam">int $fd , <span class="methodparam">string $data [, int $reactor_id ] )

public bool Swoole\Server::sendfile ( <span class="methodparam">int $fd , <span class="methodparam">string $filename [, int $offset ] )

public bool Swoole\Server::sendMessage ( <span class="methodparam">int $worker_id , string $data )

public bool Swoole\Server::sendto ( <span class="methodparam">string $ip , int $port , string $data [, <span class="type">string $server_socket ] )

public bool Swoole\Server::sendwait ( <span class="methodparam">int $fd , <span class="methodparam">string $data )

public <span class="type">ReturnType <span class="methodname">Swoole\Server::set ( <span class="methodparam">array $settings )

public void Swoole\Server::shutdown ( <span class="methodparam">void )

public void Swoole\Server::start ( <span class="methodparam">void )

public array Swoole\Server::stats ( <span class="methodparam">void )

public bool Swoole\Server::stop ([ <span class="methodparam">int $worker_id ] )

public mixed Swoole\Server::task ( <span class="methodparam">string $data [, int $dst_worker_id [, <span class="type">callable $callback ]] )

public void Swoole\Server::taskwait ( <span class="methodparam">string $data [, float $timeout [, <span class="type">int $worker_id ]] )

public void Swoole\Server::taskWaitMulti ( <span class="methodparam">array $tasks [, double $timeout_ms ] )

public void Swoole\Server::tick ( <span class="methodparam">int $interval_ms , callable $callback )

}

预定义常量

Swoole\Redis\Server::NIL

Swoole\Redis\Server::ERROR

Swoole\Redis\Server::STATUS

Swoole\Redis\Server::INT

Swoole\Redis\Server::STRING

Swoole\Redis\Server::SET

Swoole\Redis\Server::MAP

Swoole\Redis\Server::format

Description

说明

public <span class="modifier">static ReturnType Swoole\Redis\Server::format ( <span class="methodparam">string $type [, string $value ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

type

value

返回值

Swoole\Redis\Server::setHandler

Description

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Redis\Server::setHandler ( <span class="methodparam">string $command , string $callback [, <span class="type">string $number_of_string_param [, <span class="methodparam">string $type_of_array_param ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

command

callback

number_of_string_param

type_of_array_param

返回值

Swoole\Redis\Server::start

Description

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Redis\Server::start ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Serialize

class Swoole\Serialize {

/* 方法 */

public <span class="modifier">static ReturnType pack ( <span class="type">string $data [, <span class="methodparam">int $is_fast ] )

public <span class="modifier">static ReturnType unpack ( <span class="type">string $data [, <span class="methodparam">string $args ] )

}

Swoole\Serialize::pack

Serialize the data.

说明

public <span class="modifier">static ReturnType Swoole\Serialize::pack ( <span class="methodparam">string $data [, int $is_fast ] )

Swoole provides a fast and high performance serialization module.

参数

data

is_fast

返回值

Swoole\Serialize::unpack

Unserialize the data.

说明

public <span class="modifier">static ReturnType Swoole\Serialize::unpack ( <span class="methodparam">string $data [, string $args ] )

Unserialize the data.

参数

string

args

返回值

简介

类摘要

Swoole\Server

class Swoole\Server {

/* 方法 */

public void addlistener ( <span class="methodparam">string $host , int $port , string $socket_type )

public bool addProcess ( <span class="methodparam">swoole_process $process )

public <span class="type">ReturnType after ( int $after_time_ms , <span class="type">callable $callback [, <span class="methodparam">string $param ] )

public bool bind ( <span class="type">int $fd , <span class="type">int $uid )

public void clearTimer ( <span class="methodparam">int $timer_id )

void <span class="methodname">swoole_timer_clear ( <span class="methodparam">int $timer_id )

public bool close ( <span class="type">int $fd [, <span class="type">bool $reset ] )

public bool confirm ( <span class="methodparam">int $fd )

public array connection_info ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

public array connection_list ( <span class="methodparam">int $start_fd [, int $pagesize ] )

public void defer ( <span class="type">callable $callback )

public bool exist ( <span class="type">int $fd )

public void finish ( <span class="type">string $data )

public <span class="type">ReturnType <span class="methodname">getClientInfo ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

public array getClientList ( <span class="methodparam">int $start_fd [, int $pagesize ] )

public int <span class="methodname">getLastError ( <span class="methodparam">void )

public mixed heartbeat ( <span class="methodparam">bool $if_close_connection )

public bool listen ( <span class="type">string $host , <span class="methodparam">int $port , <span class="methodparam">string $socket_type )

public void on ( <span class="type">string $event_name , <span class="methodparam">callable $callback )

public void pause ( <span class="type">int $fd )

public void protect ( <span class="methodparam">int $fd [, <span class="methodparam">bool $is_protected ] )

public bool reload ( <span class="methodparam">void )

public void resume ( <span class="type">int $fd )

public bool send ( <span class="type">int $fd , <span class="type">string $data [, <span class="methodparam">int $reactor_id ] )

public bool sendfile ( <span class="methodparam">int $fd , <span class="methodparam">string $filename [, int $offset ] )

public bool sendMessage ( <span class="methodparam">int $worker_id , string $data )

public bool sendto ( <span class="type">string $ip , <span class="methodparam">int $port , <span class="methodparam">string $data [, string $server_socket ] )

public bool sendwait ( <span class="methodparam">int $fd , <span class="methodparam">string $data )

public <span class="type">ReturnType set ( array $settings )

public void shutdown ( <span class="methodparam">void )

public void start ( <span class="methodparam">void )

public array stats ( <span class="methodparam">void )

public bool stop ([ <span class="type">int $worker_id ] )

public mixed task ( <span class="type">string $data [, <span class="methodparam">int $dst_worker_id [, <span class="type">callable $callback ]] )

public void taskwait ( <span class="methodparam">string $data [, float $timeout [, <span class="type">int $worker_id ]] )

public void taskWaitMulti ( <span class="methodparam">array $tasks [, double $timeout_ms ] )

public void tick ( <span class="type">int $interval_ms , <span class="methodparam">callable $callback )

}

Swoole\Server::addlistener

Add a new listener to the server.

说明

public void Swoole\Server::addlistener ( <span class="methodparam">string $host , int $port , string $socket_type )

参数

host

port

socket_type

返回值

Swoole\Server::addProcess

Add a user defined swoole_process to the server.

说明

public bool Swoole\Server::addProcess ( <span class="methodparam">swoole_process $process )

参数

process

返回值

Swoole\Server::after

Trigger a callback function after a period of time.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Server::after ( <span class="methodparam">int $after_time_ms , <span class="type">callable $callback [, <span class="methodparam">string $param ] )

参数

after_time_ms

callback

param

返回值

Swoole\Server::bind

Bind the connection to a user defined user ID.

说明

public bool Swoole\Server::bind ( <span class="methodparam">int $fd , <span class="methodparam">int $uid )

参数

fd

uid

返回值

Swoole\Server::clearTimer

swoole_timer_clear

Stop and destory a timer.

说明

面向对象风格 (method):

public void Swoole\Server::clearTimer ( <span class="methodparam">int $timer_id )

过程化风格:

void <span class="methodname">swoole_timer_clear ( <span class="methodparam">int $timer_id )

Stop and destory a timer

参数

timer_id

返回值

Swoole\Server::close

Close a connection to the client.

说明

public bool Swoole\Server::close ( <span class="methodparam">int $fd [, <span class="methodparam">bool $reset ] )

参数

fd

reset

返回值

Swoole\Server::confirm

Check status of the connection.

说明

public bool Swoole\Server::confirm ( <span class="methodparam">int $fd )

参数

fd

返回值

Swoole\Server::connection_info

Get the connection info by file description.

说明

public array Swoole\Server::connection_info ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

参数

fd

reactor_id

返回值

Swoole\Server::connection_list

Get all of the established connections.

说明

public array Swoole\Server::connection_list ( <span class="methodparam">int $start_fd [, int $pagesize ] )

参数

start_fd

pagesize

返回值

Swoole\Server::__construct

Construct a Swoole server.

说明

public <span class="methodname">Swoole\Server::__construct ( <span class="methodparam">string $host [, int $port [, integr $mode [, <span class="type">int $sock_type ]]] )

参数

host

port

mode

sock_type

Swoole\Server::defer

Delay execution of the callback function at the end of current EventLoop.

说明

public void Swoole\Server::defer ( <span class="methodparam">callable $callback )

参数

callback

返回值

Swoole\Server::exist

Check if the connection is existed.

说明

public bool Swoole\Server::exist ( <span class="methodparam">int $fd )

参数

fd

返回值

Swoole\Server::finish

Used in task process for sending result to the worker process when the task is finished.

说明

public void Swoole\Server::finish ( <span class="methodparam">string $data )

参数

data

返回值

Swoole\Server::getClientInfo

Get the connection info by file description.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Server::getClientInfo ( <span class="methodparam">int $fd [, <span class="methodparam">int $reactor_id ] )

参数

fd

reactor_id

返回值

Swoole\Server::getClientList

Get all of the established connections.

说明

public array Swoole\Server::getClientList ( <span class="methodparam">int $start_fd [, int $pagesize ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

start_fd

pagesize

返回值

Swoole\Server::getLastError

Get the error code of the most recent error.

说明

public int <span class="methodname">Swoole\Server::getLastError ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Server::heartbeat

Check all the connections on the server.

说明

public mixed Swoole\Server::heartbeat ( <span class="methodparam">bool $if_close_connection )

参数

if_close_connection

返回值

Swoole\Server::listen

Listen on the given IP and port, socket type.

说明

public bool Swoole\Server::listen ( <span class="methodparam">string $host , int $port , string $socket_type )

参数

host

port

socket_type

返回值

Swoole\Server::on

Register a callback function by event name.

说明

public void Swoole\Server::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

参数

event_name

callback

返回值

Swoole\Server::pause

Stop receiving data from the connection.

说明

public void Swoole\Server::pause ( <span class="methodparam">int $fd )

参数

fd

返回值

Swoole\Server::protect

Set the connection to be protected mode.

说明

public void Swoole\Server::protect ( <span class="methodparam">int $fd [, <span class="methodparam">bool $is_protected ] )

参数

fd

is_protected

返回值

Swoole\Server::reload

Restart all the worker process.

说明

public bool Swoole\Server::reload ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Server::resume

Start receving data from the connection.

说明

public void Swoole\Server::resume ( <span class="methodparam">int $fd )

参数

fd

返回值

Swoole\Server::send

Send data to the client.

说明

public bool Swoole\Server::send ( <span class="methodparam">int $fd , <span class="methodparam">string $data [, int $reactor_id ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

fd

data

reactor_id

返回值

Swoole\Server::sendfile

Send file to the connection.

说明

public bool Swoole\Server::sendfile ( <span class="methodparam">int $fd , <span class="methodparam">string $filename [, int $offset ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

fd

filename

offset

返回值

Swoole\Server::sendMessage

Send message to worker processes by ID.

说明

public bool Swoole\Server::sendMessage ( <span class="methodparam">int $worker_id , string $data )

参数

dst_worker_id

data

返回值

Swoole\Server::sendto

Send data to the remote UDP address.

说明

public bool Swoole\Server::sendto ( <span class="methodparam">string $ip , int $port , string $data [, <span class="type">string $server_socket ] )

参数

ip

port

data

server_socket

返回值

Swoole\Server::sendwait

Send data to the remote socket in the blocking way.

说明

public bool Swoole\Server::sendwait ( <span class="methodparam">int $fd , <span class="methodparam">string $data )

Warning

本函数还未编写文档,仅有参数列表。

参数

fd

data

返回值

Swoole\Server::set

Set the runtime settings of the swoole server.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Server::set ( <span class="methodparam">array $settings )

Set the runtime settings of the swoole server. The settings can be accessed by $server->setting when the swoole server has started.

参数

settings

返回值

Swoole\Server::shutdown

Shutdown the master server process, this function can be called in worker processes.

说明

public void Swoole\Server::shutdown ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Server::start

Start the Swoole server.

说明

public void Swoole\Server::start ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Server::stats

Get the stats of the Swoole server.

说明

public array Swoole\Server::stats ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Server::stop

Stop the Swoole server.

说明

public bool Swoole\Server::stop ([ <span class="methodparam">int $worker_id ] )

参数

worker_id

返回值

Swoole\Server::task

Send data to the task worker processes.

说明

public mixed Swoole\Server::task ( <span class="methodparam">string $data [, int $dst_worker_id [, <span class="type">callable $callback ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

data

dst_worker_id

callback

返回值

Swoole\Server::taskwait

Send data to the task worker processes in blocking way.

说明

public void Swoole\Server::taskwait ( <span class="methodparam">string $data [, float $timeout [, <span class="type">int $worker_id ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

data

timeout

worker_id

返回值

Swoole\Server::taskWaitMulti

Execute multiple tasks concurrently.

说明

public void Swoole\Server::taskWaitMulti ( <span class="methodparam">array $tasks [, double $timeout_ms ] )

参数

tasks

timeout_ms

返回值

Swoole\Server::tick

Repeats a given function at every given time-interval.

说明

public void Swoole\Server::tick ( <span class="methodparam">int $interval_ms , callable $callback )

参数

interval_ms

callback

返回值

简介

类摘要

Swoole\Table

class Swoole\Table <span class="oointerface">implements <span class="interfacename">Iterator <span class="oointerface">, Countable {

/* Constants */

const int Swoole\Table::TYPE_INT = 1 ;

const int Swoole\Table::TYPE_STRING = 7 ;

const int Swoole\Table::TYPE_FLOAT = 6 ;

/* 方法 */

public <span class="type">ReturnType column ( string $name , <span class="type">string $type [, <span class="methodparam">int $size ] )

public int <span class="methodname">count ( void )

public void create ( <span class="methodparam">void )

public array current ( <span class="methodparam">void )

public <span class="type">ReturnType decr ( string $key , string $column [, <span class="type">int $decrby ] )

public void del ( <span class="type">string $key )

public void destroy ( <span class="methodparam">void )

public bool exist ( <span class="type">string $key )

public int <span class="methodname">get ( <span class="type">string $row_key , <span class="methodparam">string $column_key )

public void incr ( <span class="type">string $key , <span class="methodparam">string $column [, int $incrby ] )

public string key ( <span class="methodparam">void )

public <span class="type">ReturnType next ( void )

public void rewind ( <span class="methodparam">void )

public VOID set ( <span class="type">string $key , <span class="methodparam">array $value )

public bool valid ( <span class="methodparam">void )

}

预定义常量

Swoole\Table::TYPE_INT

Swoole\Table::TYPE_STRING

Swoole\Table::TYPE_FLOAT

Swoole\Table::column

Set the data type and size of the columns.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Table::column ( <span class="methodparam">string $name , string $type [, <span class="type">int $size ] )

参数

name

type

size

返回值

Swoole\Table::__construct

Construct a Swoole memory table with fixed size.

说明

public <span class="methodname">Swoole\Table::__construct ( <span class="methodparam">int $table_size )

参数

table_size

Swoole\Table::count

Count the rows in the table, or count all the elements in the table if $mode = 1.

说明

public int <span class="methodname">Swoole\Table::count ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Table::create

Create the swoole memory table.

说明

public void Swoole\Table::create ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Table::current

Get the current row.

说明

public array Swoole\Table::current ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Table::decr

Decrement the value in the Swoole table by $row_key and $column_key.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Table::decr ( <span class="methodparam">string $key , string $column [, <span class="type">int $decrby ] )

参数

key

column

decrby

返回值

Swoole\Table::del

Delete a row in the Swoole table by $row_key.

说明

public void Swoole\Table::del ( <span class="methodparam">string $key )

参数

key

返回值

Swoole\Table::destroy

Destroy the Swoole table.

说明

public void Swoole\Table::destroy ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Table::exist

Check if a row is existed by $row_key.

说明

public bool Swoole\Table::exist ( <span class="methodparam">string $key )

参数

key

返回值

Swoole\Table::get

Get the value in the Swoole table by $row_key and $column_key.

说明

public int <span class="methodname">Swoole\Table::get ( <span class="methodparam">string $row_key , string $column_key )

参数

row_key

column_key

返回值

Swoole\Table::incr

Increment the value by $row_key and $column_key.

说明

public void Swoole\Table::incr ( <span class="methodparam">string $key , string $column [, <span class="type">int $incrby ] )

参数

key

column

incrby

返回值

Swoole\Table::key

Get the key of current row.

说明

public string Swoole\Table::key ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Table::next

Iterator the next row.

说明

public <span class="type">ReturnType <span class="methodname">Swoole\Table::next ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Table::rewind

Rewind the iterator.

说明

public void Swoole\Table::rewind ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

Swoole\Table::set

Update a row of the table by $row_key.

说明

public VOID Swoole\Table::set ( <span class="methodparam">string $key , array $value )

参数

key

value

返回值

Swoole\Table::valid

Check current if the current row is valid.

说明

public bool Swoole\Table::valid ( <span class="methodparam">void )

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Timer

class Swoole\Timer {

/* 方法 */

public <span class="modifier">static void <span class="methodname">after ( <span class="type">int $after_time_ms , <span class="methodparam">callable $callback )

public <span class="modifier">static void <span class="methodname">clear ( <span class="type">int $timer_id )

public <span class="modifier">static bool <span class="methodname">exists ( <span class="type">int $timer_id )

public <span class="modifier">static void <span class="methodname">tick ( <span class="type">int $interval_ms , <span class="methodparam">callable $callback [, <span class="type">string $param ] )

}

Swoole\Timer::after

Trigger a callback function after a period of time.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Timer::after ( <span class="methodparam">int $after_time_ms , <span class="type">callable $callback )

Trigger a callback function after a period of time.

参数

after_time_ms

callback

返回值

Swoole\Timer::clear

Delete a timer by timer ID.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Timer::clear ( <span class="methodparam">int $timer_id )

Delete a timer by timer ID.

参数

timer_id

返回值

Swoole\Timer::exists

Check if a timer is existed.

说明

public <span class="modifier">static bool <span class="methodname">Swoole\Timer::exists ( <span class="methodparam">int $timer_id )

Check if a timer is existed.

参数

timer_id

返回值

Swoole\Timer::tick

Repeats a given function at every given time-interval.

说明

public <span class="modifier">static void <span class="methodname">Swoole\Timer::tick ( <span class="methodparam">int $interval_ms , callable $callback [, <span class="type">string $param ] )

参数

interval_ms

callback

param

返回值

简介

类摘要

Swoole\WebSocket\Frame

class Swoole\WebSocket\Frame {

/* 方法 */

}

简介

类摘要

Swoole\WebSocket\Server

class Swoole\WebSocket\Server <span class="ooclass"> extends Swoole\Http\Server {

/* 方法 */

public bool exist ( <span class="type">int $fd )

public <span class="type">ReturnType on ( string $event_name , <span class="type">callable $callback )

public <span class="modifier">static binary <span class="methodname">pack ( <span class="type">string $data [, <span class="methodparam">string $opcode [, string $finish [, <span class="type">string $mask ]]] )

public void push ( <span class="type">string $fd , <span class="methodparam">string $data [, string $opcode [, <span class="type">string $finish ]] )

public <span class="modifier">static string <span class="methodname">unpack ( <span class="type">binary $data )

/* 继承的方法 */

public void Swoole\Http\Server::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

public void Swoole\Http\Server::start ( <span class="methodparam">void )

}

Swoole\WebSocket\Server::exist

Check if the file descriptor exists.

说明

public bool Swoole\WebSocket\Server::exist ( <span class="methodparam">int $fd )

参数

fd

返回值

Swoole\WebSocket\Server::on

Register event callback function

说明

public <span class="type">ReturnType <span class="methodname">Swoole\WebSocket\Server::on ( <span class="methodparam">string $event_name , <span class="type">callable $callback )

Register event callback function

参数

event_name

callback

返回值

Swoole\WebSocket\Server::pack

Get a pack of binary data to send in a single frame.

说明

public <span class="modifier">static binary <span class="methodname">Swoole\WebSocket\Server::pack ( <span class="methodparam">string $data [, string $opcode [, <span class="type">string $finish [, <span class="methodparam">string $mask ]]] )

参数

data

opcode

finish

mask

返回值

Swoole\WebSocket\Server::push

Push data to the remote client.

说明

public void Swoole\WebSocket\Server::push ( <span class="methodparam">string $fd , string $data [, <span class="type">string $opcode [, <span class="methodparam">string $finish ]] )

参数

fd

data

opcode

finish

返回值

Swoole\WebSocket\Server::unpack

Unpack the binary data received from the client.

说明

public <span class="modifier">static string <span class="methodname">Swoole\WebSocket\Server::unpack ( <span class="methodparam">binary $data )

参数

data

返回值


本站为非盈利网站,作品由网友提供上传,如无意中有侵犯您的版权,请联系删除