Created
June 28, 2016 07:46
-
-
Save Maras0830/f781739d7b82534857a7d46dc9109f42 to your computer and use it in GitHub Desktop.
views/push.blade.php
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Laravel</title> | |
<script src="/bower_components/jquery/dist/jquery.js"></script> | |
<script src="https://js.pusher.com/3.1/pusher.min.js"></script> | |
<style> | |
#message { | |
height:300px; | |
width:30% | |
background-color: #cccccc; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-6 col-md-offset-3"> | |
<h1>Laravel Event Broadcasting Demo</h1> | |
<!-- 訊息列表 --> | |
<div id="message"> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
<script> | |
// Enable pusher logging - don't include this in production | |
Pusher.logToConsole = true; | |
var pusher = new Pusher('{{env('PUSHER_KEY','')}}', { | |
cluster: 'ap1', | |
encrypted: true | |
}); | |
var channel = pusher.subscribe('laravel-tutorial-event-channel-{{$member_id}}'); | |
channel.bind('App\\Events\\SendMessage', function(data) { | |
$('#message').append('<p>'+data.username + ': '+ data.message + '</p>'); | |
}); | |
</script> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment