forked from jxy918/swoole-game
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
$server = new swoole_websocket_server("0.0.0.0", 9501); | ||
$server->set([ | ||
'heartbeat_check_interval' => 1, | ||
'heartbeat_idle_time' => 10 | ||
]); | ||
|
||
$server->on('open', function (swoole_websocket_server $server, $request) { | ||
echo "server: handshake success with fd{$request->fd}\n"; | ||
}); | ||
|
||
$server->on('message', function (swoole_websocket_server $server, $frame) { | ||
echo "receive from {$frame->fd}:{$frame->data},opcode:{$frame->opcode},fin:{$frame->finish}\n"; | ||
$server->push($frame->fd, "this is server"); | ||
}); | ||
|
||
$server->on('close', function ($ser, $fd) { | ||
echo "client {$fd} closed\n"; | ||
}); | ||
|
||
$server->start(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[2018-10-08 18:17:28 @2971.0] TRACE hb timer start, time: 30 live time:60 | ||
[2018-10-08 18:17:28 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:17:29 *2980.1] DEBUG Context(:16): alloc stack: size=2097152, ptr=0x7f19edb2b010. | ||
[2018-10-08 18:17:29 *2979.0] DEBUG Context(:16): alloc stack: size=2097152, ptr=0x7f19ed82a010. | ||
[2018-10-08 18:17:29 *2979.0] DEBUG ~Context(:38): free stack: ptr=0x7f19ed82a010 | ||
[2018-10-08 18:17:29 *2980.1] DEBUG ~Context(:38): free stack: ptr=0x7f19edb2b010 | ||
[2018-10-08 18:17:58 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:18:28 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:18:58 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:19:28 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:19:58 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:20:28 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:20:58 #2971.1] TRACE check fd=5 | ||
[2018-10-08 18:21:09 @2984.0] TRACE hb timer start, time: 30 live time:60 | ||
[2018-10-08 18:21:09 #2984.1] TRACE check fd=5 | ||
[2018-10-08 18:21:10 *2992.0] DEBUG Context(:16): alloc stack: size=2097152, ptr=0x7f869222a010. | ||
[2018-10-08 18:21:10 *2992.0] DEBUG ~Context(:38): free stack: ptr=0x7f869222a010 | ||
[2018-10-08 18:21:10 *2993.1] DEBUG Context(:16): alloc stack: size=2097152, ptr=0x7f869252b010. | ||
[2018-10-08 18:21:10 *2993.1] DEBUG ~Context(:38): free stack: ptr=0x7f869252b010 | ||
[2018-10-08 18:21:39 #2984.1] TRACE check fd=5 |