forked from kakajansh/echo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
# echo | ||
## Laravel Echo for Flutter | ||
|
||
Laravel Echo for your Flutter apps. | ||
Basically, this package is port of official [Laravel Echo javascript library](https://github.com/laravel/echo). It helps subscribe to channels and listen for events broadcast from your Laravel app. | ||
|
||
Three connectors available: | ||
- [ ] Pusher | ||
- [x] Socket.io | ||
- [x] Null | ||
|
||
## Getting started | ||
|
||
For now, only `socket.io` connector implemented. You need to install [socket_io_client](https://pub.dartlang.org/packages/socket_io_client) for your Flutter app. | ||
|
||
In your `pubspec.yaml` file: | ||
|
||
```yaml | ||
dependencies: | ||
... | ||
socket_io_client: ^0.9.1 | ||
laravel_echo: | ||
``` | ||
#### Usage: | ||
```dart | ||
IO.Socket socket = IO.io('http://localhost:6001', <String, dynamic>{'transports': ['websocket']}); | ||
|
||
Echo echo = new Echo({ | ||
'broadcaster': 'socket.io', | ||
'client': socket, | ||
'broadcaster': 'socket.io', | ||
'client': socket, | ||
}); | ||
|
||
echo.channel('channel-name').listen('EventName', (e) { | ||
print(e); | ||
echo.channel('test').listen('TestEvent', (e) { | ||
print(e); | ||
}); | ||
``` | ||
|
||
socket.on('connect', (_) => print('connect')); | ||
socket.on('disconnect', (_) => print('disconnect')); | ||
``` | ||
|
||
Package by [Kakajan SH](http://kakajan.sh) |