pusher_advance

Creator: coderz1093

Last updated:

0 purchases

pusher_advance Image
pusher_advance Images
Add to Cart

Description:

pusher advance

Pusher HTTP Dart Library #

The Dart library for interacting with the Pusher HTTP API.
This package lets you trigger events to your client and query the state of your Pusher channels. When used with a server, you can authenticate private- or presence-channels.
In order to use this library, you need to have a free account on http://pusher.com. After registering, you will need the application credentials for your app.
Getting Started #

import 'package:pusher/pusher_advance.dart';

main() async {
Pusher pusher = new Pusher('PUSHER_APP_ID','PUSHER_APP_KEY','PUSHER_APP_SECRET');
Map data = {'message':'Hello world'};
Response response = await pusher.trigger(['test_channel'],'my_event',data);
}

copied to clipboard
Configuration #
There easiest way to configure the library is by creating a new Pusher instance:
Pusher pusher = new Pusher(
'PUSHER_APP_ID',
'PUSHER_APP_KEY',
'PUSHER_APP_SECRET'
);
copied to clipboard
Additional options #
PusherOptions options = new PusherOptions(encrypted: true);
Pusher pusher = new Pusher(
'PUSHER_APP_ID',
'PUSHER_APP_KEY',
'PUSHER_APP_SECRET',
options
);
copied to clipboard
Usage #
Triggering events #
It is possible to trigger an event on one or more channels. Channel names can contain only characters which are alphanumeric, _ or `-``. Event name can be at most 200 characters long too.
Response response = await pusher.trigger(['test_channel'],'my_event',data);
copied to clipboard
Authenticating Channels #
Pusher provides a mechanism for authenticating a user's access to a channel at the point of subscription.
This can be used both to restrict access to private channels, and in the case of presence channels notify subscribers of who else is also subscribed via presence events.
This library provides a mechanism for generating an authentication signature to send back to the client and authorize them.
For more information see docs.
Private channels
String socketId = '74124.3251944';
String auth = pusher.authenticate('test_channel',socketId);
copied to clipboard
Authenticating presence channels
Using presence channels is similar to private channels, but in order to identify a user, clients are sent a user_id and, optionally, custom data.
String socketId = '74124.3251944';
User user = new User('1',{'name':'Adao'});
String auth = pusher.authenticate('presence-test_channel',socketId,user);
copied to clipboard
It is possible to query the state of your Pusher application using the generic pusher.get( resource ) method and overloads.
For full details see: http://pusher.com/docs/rest_api
Application state #
This library allows you to query our API to retrieve information about your application's channels, their individual properties, and, for presence-channels, the users currently subscribed to them.
List channels
You can get a list of channels that are present within your application:
Response result = await pusher.get("/channels");
copied to clipboard
You can provide additional parameters to filter the list of channels that is returned.
Response result = await pusher.get("/channels", { "filter_by_prefix" : "presence-" } );
copied to clipboard
Fetch channel information
Retrive information about a single channel:
Response result = await pusher.get("/channels/my_channel");
copied to clipboard
Fetch a list of users on a presence channel
Retrive a list of users that are on a presence channel:
Response result = await pusher.get('/channels/presence-channel/users');
copied to clipboard
Documentation #
http://www.dartdocs.org/documentation/pusher/latest/index.html
License #
This code is free to use under the terms of the MIT license.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.