Swoole Server after

void Swoole\Server::after ( int $after_time_ms , callable $callback [, string $param ] )

Alias: Swoole\Server->after( int $after_time_ms , callable $callback [, string $param ] )

<?php
bool Swoole\Server->after(int $after_time_ms, mixed $callback)

Trigger a one time tick in the future. Alias of function swoole_timer_after(). You can remove the timer later by calling swoole_timer_clear

Parameter

  • $time the number of millisecond
  • $callable the function that triggered after with a fixed time delay

Return

the timer id which uniquely identifies the timer

Example

bool Swoole\Server::bind ( int $fd , int $uid )

Alias: Swoole\Server->bind( int $fd , int $uid )

<?php
bool Swoole\Server->bind(int $fd, int $uid)

Bind the fd with system user UID.

The dispatch of different socket connection to the swoole server is influenced by the configuration of dispatch_mode

In the default dispatch_mode which is 2, the socket connection may be dispatched to different worker process after reconnetion. You can set the configuration of dispatch_mode to 5 and call Swoole\Server->bind to bind a uid number to socket connection. And then the same uid socket connection will be dispatched to the same worker process.

Parameter

  • $fd the id number of client
  • $uid the uid number binded for the client

Return

The result of binding

Example