Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // update new message to table
- $data['chatid'] = $to_id; // use a unique random string
- // broadcast using pusher notication
- $pusher->trigger('__subscribed_channel__', '__chat_session__', $data);
- ?>
- <!-- for user notification -->
- <script type="text/javascript">
- // Enable pusher logging - don't include this in production
- Pusher.log = function(message) {
- if (window.console && window.console.log) {
- window.console.log(message);
- }
- };
- var pusher = new Pusher('__app_secret__');
- var channel = pusher.subscribe('__subscribed_channel__');
- channel.bind('gsm_chat', function(data) {
- var element = document.getElementById("new_msg");
- if (data.chatid == '<?= $_SESSION['user']['chatid']; ?>') {
- element.innerHTML = data.message;
- } else {
- element.innerHTML = '<a href="messaging.php"><div class="no_msg"></div></a>';
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement