Skip to content

Commit ca604e3

Browse files
committed
update readme for realtime messaging
1 parent 9a3aca1 commit ca604e3

1 file changed

Lines changed: 63 additions & 2 deletions

File tree

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Laravel-Talk
22

3-
Talk is a Laravel 5 based user conversation (inbox) system. You can easily integrate this package with any Laravel based project. It helps you to develop a messaging system in just few mins. Here is a project screenshot that was developed by Talk.
3+
Talk is a Laravel 5 based user conversation (inbox) system with realtime messaging. You can easily integrate this package with any Laravel based project. It helps you to develop a messaging system in just few mins. Here is a project screenshot that was developed by Talk.
4+
5+
> Talk v2.1.0 is supported realtime messaging. Learn more about [Talk Live Messaging](https://github.com/nahid/talk#realtime-messaging)
46
57
> Talk v2.0.0 just released. Do not migrate 1.1.7 to v2.0.0 directly. Please try our [sample project](https://github.com/nahid/talk-example) first and then apply it on your project.
68
@@ -23,6 +25,7 @@ So let's start your tour :)
2325
### Features
2426

2527
* Head to head messaging
28+
* Realtime messaging
2629
* Creating new conversation
2730
* Message threads with latest one
2831
* View conversations by user id or conversation id
@@ -73,7 +76,16 @@ Okay, now you need to configure your user model for Talk. Go to `config/talk.php
7376
```php
7477
return [
7578
'user' => [
76-
'model' => 'User\Model'
79+
'model' => 'App\User'
80+
],
81+
'broadcast' => [
82+
'enable' => false,
83+
'app_name' => 'your-app-name',
84+
'pusher' => [
85+
'app_id' => '',
86+
'app_key' => '',
87+
'app_secret' => ''
88+
]
7789
]
7890
];
7991
```
@@ -462,6 +474,55 @@ This method is used to permanently delete all conversations
462474
boolean deleteConversations($conversationId)
463475
```
464476

477+
## Realtime Messaging
478+
479+
Talk also support realtime messaging thats called Talk-Live. Talk use pusher for realtime message. So first you have to configure pusher. Go to `app/talk.php` again and configure.
480+
481+
```php
482+
return [
483+
'user' => [
484+
'model' => 'App\User'
485+
],
486+
'broadcast' => [
487+
'enable' => false,
488+
'app_name' => 'your-app-name',
489+
'pusher' => [
490+
'app_id' => '',
491+
'app_key' => '',
492+
'app_secret' => ''
493+
]
494+
]
495+
];
496+
```
497+
498+
in this new version broadcast section was added with talk config. Here broadcast is disabled by default.
499+
If you want to enable live(realtime) messaging then you have to enable it first. Then add pusher credentials. Thats it. Everytime
500+
when you send message then talk will automatically fire two event, one for specific user and second for specific conversation. So
501+
you may listen or subscribe one or both as per your wish. Finally you have to subscribe these events by using `talk_live()` helper function.
502+
Go to where you want to subscribe to work with message data follow this code.
503+
504+
```
505+
<script>
506+
var msgshow = function(data) {
507+
// write what you want with this data
508+
509+
console.log(data);
510+
}
511+
</script>
512+
513+
{!! talk_live(['user'=>["id"=>auth()->user()->id, 'callback'=>['msgshow']]]) !!}
514+
```
515+
516+
`talk_live()` is support one parameters as array. The first parameter is for channel name which you want to subscribe. You have not know which channel was broadcast.
517+
Talk broadcast two channel by default. One for user and second for conversation. If you want to subscribe channel for currently loggedin user then you have to pass
518+
519+
logedin user id in 'user' key. `['user'=>['id'=>auth()->user()->id, 'callback'=[]]` or you want to subscribe for conversation id you have pass conversation id as
520+
'conversation' key. `['conversation'=>['id'=>$conversationID, 'callback'=>[]]`. You may pass both if you wants.
521+
522+
You can pass a callback for working with pusher recieved data. For both `user` and `conversation` section support callbacks as array. So you can pass multiple callback as array value that was show in previous example.
523+
524+
You can watch [Talk-Live-Demo](https://youtu.be/bN3s_LbObnQ)
525+
465526
### Try Demo Project
466527
[Talk-Example](https://github.com/nahid/talk-example)
467528

0 commit comments

Comments
 (0)