laravel_echo_null 0.0.5+10 copy "laravel_echo_null: ^0.0.5+10" to clipboard
laravel_echo_null: ^0.0.5+10 copied to clipboard

This Package is the improved version of the original package "laravel_echo", with some modifications and features.

laravel_echo_null #

Getting started #

Important information before using #

  • The laravel_echo_null package relies on the following packages:

    Package Version URL Source
    socket_io_client 2.0.3+1 pub.dev
    pusher_client_fixed 0.0.2+2 pub.dev
    fixed-laravel-echo-server 0.0.2 npm

    To include these packages in your project, add the following dependencies to your pubspec.yaml file:

    dependencies:
      socket_io_client: ^2.0.3+1
      pusher_client_fixed: ^0.0.2+2
    

    Please note that the laravel_echo_null package requires the socket_io_client package at version 2.0.2. Additionally, to ensure compatibility with the package, use the fixed-laravel-echo-server version 0.0.1, which is available on npm. You can install it globally by running the following command:

    npm i -g @abdopr/fixed-laravel-echo-server
    

    For more information, please refer to the official documentation of fixed-laravel-echo-server.

    Make sure to add these dependencies and follow the instructions to include them properly in your project

Importing #

  • import 'package:laravel_echo_null/laravel_echo_null.dart';
    

Initializing #

  • Initialization using connector:

    //// Socket IO ////
    import 'package:socket_io_client/socket_io_client.dart' as IO;
    
    Echo<IO.Socket, SocketIoChannel> echo = Echo<IO.Socket, SocketIoChannel>(SocketIoConnector(
      'http://localhost:6001', // String: host
      nameSpace: 'nameSpace', // String?: namespace
      autoConnect: false, // bool: client connection automatically
      authHeaders: {
        'Authorization': 'Bearer token'
      },
      moreOptions: {// Map: more io options
        'transports': ['websocket']
      },
    ));
    
    ///// Pusher ////
    import 'package:pusher_client_fixed/pusher_client_fixed.dart' as PUSHER;
    
    Echo<PUSHER.PusherClient, PusherChannel> echo = Echo<PUSHER.PusherClient, PusherChannel>(PusherConnector(
      'PUSHER_APP_KEY',
      authEndPoint: 'http://localhost/broadcasting/auth', // String?: auth host
      authHeaders: { // authenticate headers
        'Authorization': 'Bearer $token',
        'Content-Type': 'application/json',
        'Accept': 'application/json',
      },
      cluster: 'PUSHER_CLUSTER', // String?: pusher cluster
      host: 'ws.pusherapp.com',
      wsPort: 80,
      wssPort: 443,
      encrypted: true,
      activityTimeout: 120000,
      pongTimeout: 30000,
      maxReconnectionAttempts: 6,
      maxReconnectGapInSeconds: 30,
      enableLogging: true,
      autoConnect: false, // bool: client connection automatically
      nameSpace: 'nameSpace',
    ));
    
  • Easy initialization:

    //// Socket IO ////
    import 'package:socket_io_client/socket_io_client.dart';
    
    Echo<IO.Socket, SocketIoChannel> echo = Echo.socket(
      'http://localhost:6001', // String: host
      nameSpace: 'nameSpace', // String?: namespace
      autoConnect: false, // bool: client connection automatically
      authHeaders: {
        'Authorization': 'Bearer token'
      },
      moreOptions: {// Map: more io options
        'transports': ['websocket']
      },
    );
    
    ///// Pusher ////
    import 'package:pusher_client_fixed/pusher_client_fixed.dart';
    
    Echo<PUSHER.PusherClient, PusherChannel> echo = Echo.pusher(
      'PUSHER_APP_KEY',
      authEndPoint: 'http://localhost/broadcasting/auth', // String?: auth host
      authHeaders: { // authenticate headers
        'Authorization': 'Bearer $token',
        'Content-Type': 'application/json',
        'Accept': 'application/json',
      },
      cluster: 'PUSHER_CLUSTER', // String?: pusher cluster
      host: 'ws.pusherapp.com',
      wsPort: 80,
      wssPort: 443
      encrypted: true,
      activityTimeout: 120000,
      pongTimeout: 30000,
      maxReconnectionAttempts: 6,
      maxReconnectGapInSeconds: 30,
      enableLogging: true,
      autoConnect: false, // bool: client connection automatically
      nameSpace: 'nameSpace',
    );
    
    

Channels #

  • // public channel
    Channel publicChannel = echo.channel('my-channel');
    publicChannel.listen('MyEvent', (data) {
      print(data);
    });
    
    // private channel
    Channel privateChannel = echo.private('my-channel.1')
    privateChannel.listen('MyEvent', (data) {
      print(data);
    });
    
    // presence channel
    PresenceChannel presenceChannel = echo.join('presence-channel');
    presenceChannel.listen((data) {
      print(data);
    });
    

Note: This Package is the improved version of the original package "laravel_echo", with some modifications and features #


Powered By Abdo-Pr #

7
likes
140
pub points
80%
popularity

Publisher

unverified uploader

This Package is the improved version of the original package "laravel_echo", with some modifications and features.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, pusher_client_fixed, socket_io_client

More

Packages that depend on laravel_echo_null