这是我的onMessage
public function onMessage(ConnectionInterface $from, $msg) {
$tempMessage = json_decode($msg, TRUE);
if ($tempMessage['type'] == 'online') {
foreach ($this->clients as $client) {
if ($client == $from) {
echo "client " . $from->resourceId . "(" . $from->remoteAddress . ") is online\n";
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以在此 $client 对象中保存值以供以后参考?
我知道可以为此保留一个数组,但它可能会变得复杂,因为我将客户端存储在文档中SplObjectStorage
我一直在关注laravel 4.2,今天尝试了laravel 5。
如何将自定义验证消息添加到 Laravel 5 中的规则?
代码示例
namespace App\Http\Requests;
use App\Http\Requests\Request;
class MyRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email',
'password' => 'required|min:8'
];
}
}
// in your controller action
public function postLogin(\App\Http\Requests\MyRequest …Run Code Online (Sandbox Code Playgroud)