Coder Social home page Coder Social logo

laravel-video-chat's Introduction

Laravel Video Chat

Laravel Video Chat using Socket.IO and WebRTC

Build Status StyleCI Latest Stable Version Total Downloads

Installation

composer require php-junior/laravel-video-chat

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

PhpJunior\LaravelVideoChat\LaravelVideoChatServiceProvider::class,
php artisan vendor:publish --provider="PhpJunior\LaravelVideoChat\LaravelVideoChatServiceProvider"

And

php artisan migrate
php artisan storage:link

change APP_URL in .env

This is the contents of the published config file:

return [
    'relation'  => [
        'conversations' =>  PhpJunior\LaravelVideoChat\Models\Conversation\Conversation::class,
        'group_conversations' => PhpJunior\LaravelVideoChat\Models\Group\Conversation\GroupConversation::class
    ],
    'user' => [
        'model' =>  App\User::class,
        'table' =>  'users' // Existing user table name
    ],
    'table' => [
        'conversations_table'   =>  'conversations',
        'messages_table'        =>  'messages',
        'group_conversations_table' =>  'group_conversations',
        'group_users_table'     =>  'group_users',
        'files_table'           =>  'files'
    ],
    'channel'   =>  [
        'new_conversation_created'  =>  'new-conversation-created',
        'chat_room'                 =>  'chat-room',
        'group_chat_room'           =>  'group-chat-room'
    ],
    'upload' => [
        'storage' => 'public'
    ]
];

Uncomment App\Providers\BroadcastServiceProvider in the providers array of your config/app.php configuration file

Install the JavaScript dependencies:

    npm install
    npm install --save laravel-echo js-cookie vue-timeago socket.io socket.io-client webrtc-adapter vue-chat-scroll

If you are running the Socket.IO server on the same domain as your web application, you may access the client library like

<script src="//{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>

in your application's head HTML element

Next, you will need to instantiate Echo with the socket.io connector and a host.

 require('webrtc-adapter');
 window.Cookies = require('js-cookie');
 
 import Echo from "laravel-echo"
 
 window.io = require('socket.io-client');
 
 window.Echo = new Echo({
     broadcaster: 'socket.io',
     host: window.location.hostname + ':6001'
 });

Finally, you will need to run a compatible Socket.IO server. Use tlaverdure/laravel-echo-server GitHub repository.

In resources/assets/js/app.js file:

 import VueChatScroll from 'vue-chat-scroll';
 import VueTimeago from 'vue-timeago';
 
 Vue.use(VueChatScroll);
 Vue.component('chat-room' , require('./components/laravel-video-chat/ChatRoom.vue'));
 Vue.component('group-chat-room', require('./components/laravel-video-chat/GroupChatRoom.vue'));
 Vue.component('video-section' , require('./components/laravel-video-chat/VideoSection.vue'));
 Vue.component('file-preview' , require('./components/laravel-video-chat/FilePreview.vue'));
 
 Vue.use(VueTimeago, {
     name: 'timeago', // component name, `timeago` by default
     locale: 'en-US',
     locales: {
         'en-US': require('vue-timeago/locales/en-US.json')
     }
 })

Run npm run dev to recompile your assets.

Features

  • One To One Chat ( With Video Call )
  • Accept Message Request
  • Group Chat
  • File Sharing

Usage

Get All Conversation and Group Conversation

$groups = Chat::getAllGroupConversations();
$conversations = Chat::getAllConversations()
<ul class="list-group">
    @foreach($conversations as $conversation)
        <li class="list-group-item">
        @if($conversation->message->conversation->is_accepted)
            <a href="#">
                <h2>{{$conversation->user->name}}</h2>
                @if(!is_null($conversation->message))
                    <span>{{ substr($conversation->message->text, 0, 20)}}</span>
                @endif
            </a>
         @else
            <a href="#">
                <h2>{{$conversation->user->name}}</h2>
                @if($conversation->message->conversation->second_user_id == auth()->user()->id)
                    <a href="accept_request_route" class="btn btn-xs btn-success">
                        Accept Message Request
                    </a>
                @endif
            </a>
         @endif
        </li>
    @endforeach

    @foreach($groups as $group)
        <li class="list-group-item">
            <a href="#">
                <h2>{{$group->name}}</h2>
                <span>{{ $group->users_count }} Member</span>
            </a>
        </li>
    @endforeach
</ul>

Start Conversation

Chat::startConversationWith($otherUserId);

Accept Conversation

Chat::acceptMessageRequest($conversationId);

Get Conversation Messages

$conversation = Chat::getConversationMessageById($conversationId);
<chat-room :conversation="{{ $conversation }}" :current-user="{{ auth()->user() }}"></chat-room>

Send Message

You can change message send route in component

Chat::sendConversationMessage($conversationId, $message);

Start Video Call ( Not Avaliable On Group Chat )

You can change video call route . I defined video call route trigger/{id} method POST Use $request->all() for video call.

Chat::startVideoCall($conversationId , $request->all());

Start Group Conversation

Chat::createGroupConversation( $groupName , [ $otherUserId , $otherUserId2 ]);

Get Group Conversation Messages

$conversation = Chat::getGroupConversationMessageById($groupConversationId);
<group-chat-room :conversation="{{ $conversation }}" :current-user="{{ auth()->user() }}"></group-chat-room>

Send Group Chat Message

You can change message send route in component

Chat::sendGroupConversationMessage($groupConversationId, $message);

Add Members to Group

Chat::addMembersToExistingGroupConversation($groupConversationId, [ $otherUserId , $otherUserId2 ])

Remove Members from Group

Chat::removeMembersFromGroupConversation($groupConversationId, [ $otherUserId , $otherUserId2 ])

Leave From Group

Chat::leaveFromGroupConversation($groupConversationId);

File Sharing

Run this command php artisan storage:link

Send Files in Conversation

Chat::sendFilesInConversation($conversationId , $request->file('files'));

Send Files in Group Conversation

Chat::sendFilesInGroupConversation($groupConversationId , $request->file('files'));

ToDo

  • Add Members to Group
  • Remove Member From Group

Next Version

  • Group Video Call

Credits

  • All Contributors

License

The MIT License (MIT). Please see License File for more information.

Demo Project

Support on Beerpay

Hey dude! Help me out for a couple of ๐Ÿป!

Beerpay Beerpay

laravel-video-chat's People

Contributors

phpjunior avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-video-chat's Issues

How can I thats?

I just want to call a one-sided video and rebroadcast it directly without an approval process?

Import Echo from Laravel-echo not defined

Hello, i have done your setup step by step but im kind of lost with this code
`require('webrtc-adapter');
window.Cookies = require('js-cookie');

import Echo from "laravel-echo"

window.io = require('socket.io-client');

window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});`
I put that on my App's head element, but i got this error

Import Echo from Laravel-echo not defined

what should i do? nice work tho, really appreciate it

Vue-timeago / Dependency not found

Hi,
On final npmrun dev, I have error on vue-timeago.

`This dependency was not found:

  • vue-timeago/locales/en-US.json in ./resources/js/bootstrap.js

To install it, you can run: npm install --save vue-timeago/locales/en-US.json
Asset Size Chunks Chunk Names
/css/app.css 171 KiB /js/app [emitted] /js/app
/js/app.js 1.89 MiB /js/app [emitted] /js/app`

I tried install vue-timeago, change version Laravel project, but always same error.

save file

hi can i save voice/video chat file in my host?

Invalid SDP on start video call

Hello,

I am implementing Text and Video chat using your package in laravel 5.6.

All things are working fine in text chat, nothing issue in it. But my problem is in video chat.

When i start video call and opponent clicked on Answer button here is an error showing in developer console.

image

Can you guide me in this. I don't have any idea about SDP.

Thank you !!!

Member data for presence channel missing

(node:18579) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at /home/igor/.nvm/versions/node/v10.0.0/lib/node_modules/laravel-echo-server/dist/channels/presence-channel.js:73:21
    at process._tickCallback (internal/process/next_tick.js:178:7)
(node:18579) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
[12:56:23] - ZAV0mY7odwV3er92AAAG authenticated for: presence-group-chat-room-1
Unable to join channel. Member data for presence channel missing
` ` `

VERY IMPORANT AND URGENT !!

Hello Nyi Nyi Lwin

I'm very happy to contact you , I saw your script laravel-video-chat on github
I like it but I' note able to install it in my FTP website ! please I need your help , if you can instal it in my website via filzilla ! I have a loooooow budget but I can pay you 10 euros ! please to reply me it's URGENT ! if you can't you can guide me to install it my self . thank you so much I will wait your reply .

Here is my email : [email protected]

Best regards .

Demo

Is there a demo of this available?

Trying to get property 'conversation' of non-object

I have just tried to run your demo codes after everything has been installed into the domain server. The error encountered into my laravel 7 application. Let me show you where actually the issue occurred.
This is home.blade.php

@foreach($threads as $inbox)
                       @if($inbox->message->conversation->is_accepted) <!-- This is the line of code where error has been encountered -->
                           <a href="{{ route('chat' , [
                               'id' => $inbox->message->conversation->id
                           ]) }}">
                               <div class="about">
                                   <div class="name">{{$inbox->user->name}}</div>
                                   <div class="status">
                                       @if(auth()->user()->id == $inbox->message->sender->id)
                                           <span class="fa fa-reply"></span>
                                       @endif
                                       <span>{{ substr($inbox->message->text, 0, 20)}}</span>
                                   </div>
                               </div>
                           </a>
                       @else
                           <a href="#">
                               <div class="about">
                                   <div class="name">{{$inbox->user->name}}</div>
                                   <div class="status">
                                       @if(auth()->user()->id == $inbox->message->sender->id)
                                           <span class="fa fa-reply"></span>
                                       @endif
                                       <span>{{ substr($inbox->message->text, 0, 20)}}</span>
                                   </div>
                                   @if($inbox->message->conversation->second_user_id == auth()->user()->id)
                                       <div>
                                           <a href="{{ route('accept.message' , [
                               'id' => $inbox->message->conversation->id
                           ]) }}" class="btn btn-xs btn-success">Accept Message Request</a>
                                       </div>
                                   @endif
                               </div>
                           </a>
                       @endif

               @endforeach

This is HomeController.php index()

public function index()
   {
       $groups = Chat::getAllGroupConversations();
       $threads = Chat::getAllConversations();

       return view('home')->with([
           'threads' => $threads,
           'groups'  => $groups
       ]);
   }

When I dump and die into the $threads[0]->message, I find #relations null

Laravel version

Is this plug-in would work on 5.6 too or nor?
I need video, audio and file-share chat with db in laravel 5.6.

Chat room not visible

I've followed every step mentioned herein Laravel Video Chat. But I can't see the chat room.
Please let me know if something more needed to be done besides what mentioned in README.md also let me know if I can customize the chat room.
Thanks in advance.

Not working in Laravel 5.7.19

I add this package in fresh Laravel 5.7.19 installation.
But it didn't work.
I think there is something wrong with publish because:

  1. Vuejs component folder is empty
  2. There is no eloquent model
  3. I think it's enough

Also a modification need to be added to vue-timeago in app.js:

Vue.use(VueTimeago, {
    name: 'timeago', // component name, `timeago` by default
    locale: 'en'
});

Installation

what to do next after installing the package i am in packages installation and there working ..
any video guide ?

How to config Broadcast auth?

Do I need any additional config for my broadcasting channel?
I get the following error:

[17:31:30] - L7Va97-A9KnTeyKAAAAg joined channel: presence-chat-room-2
[17:32:14] - L7Va97-A9KnTeyKAAAAg left channel: presence-chat-room-2 (transport close)
(node:43948) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 32): TypeError: Cannot convert undefined or null to object
[17:32:15] - 2GrnyNLr3KEog69rAAAh authenticated for: presence-chat-room-2
Unable to join channel. Member data for presence channel missing
[17:32:15] - 2GrnyNLr3KEog69rAAAh joined channel: presence-chat-room-2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.