PHP Classes

File: src/helpers/talk.php

Recommend this page to a friend!
  Classes of Nahid Bin Azhar   Laravel Talk   src/helpers/talk.php   Download  
File: src/helpers/talk.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Laravel Talk
Manage a multiple user conversation system
Author: By
Last change: Merge branch 'master' into master
Date: 3 years ago
Size: 1,461 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by PhpStorm.
 * User: nahid
 * Date: 12/7/16
 * Time: 4:58 PM.
 */

use Illuminate\Support\Arr;

if (!
function_exists('talk_live')) {
    function
talk_live($options)
    {
       
$talk__appKey = config('talk.broadcast.pusher.app_key');
       
$talk__appName = config('talk.broadcast.app_name');
       
$talk__options = config('talk.broadcast.pusher.options');
        if(
config('talk.broadcast.driver') === 'laravel-websockets'){
           
$talk__options = Arr::only($talk__options, [
               
'wsHost', 'wsPort', 'forceTLS', 'disableStats'
           
]);
        }
       
$talk__options = json_encode($talk__options);

       
$talk_user_channel = isset($options['user']['id']) ? $talk__appName.'-user-'.$options['user']['id'] : '';
       
$talk_conversation_channel = isset($options['conversation']['id']) ? $talk__appName.'-conversation-'.$options['conversation']['id'] : '';
       
$talk__userChannel['name'] = sha1($talk_user_channel);
       
$talk__conversationChannel['name'] = sha1($talk_conversation_channel);
       
$talk__userChannel['callback'] = isset($options['user']['callback']) ? $options['user']['callback'] : [];
       
$talk__conversationChannel['callback'] = isset($options['conversation']['callback']) ? $options['conversation']['callback'] : [];

        return
view('talk::pusherjs', compact('talk__appKey', 'talk__options', 'talk__userChannel', 'talk__conversationChannel'))->render();
    }
}