Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

monde-sistemas/pusher-http-delphi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pusher Delphi Server Library

This is a Delphi library for interacting with the Pusher HTTP API.

Register at http://pusher.com and use the application credentials within your app as shown below.

More general documentation can be found at http://pusher.com/docs/.

This library is based on Pusher .NET HTTP library and uses the .NET lib as a DLL (see dotnet folder), so, this lib depends on .NET 4.5.

Tested on Delphi XE7 but should work in any XE+ version.

Looking for a client library? Take a look at pusher-websocket-delphi

Limitations

So far this lib only supports trigger messages to public channels. The .net library has support to privates and presence channels, webhooks, etc, so, we only need to write the wrappers.

Dependencies

  • RestSharp.dll
  • PusherServer.dll
  • PusherServerNative.dll

All of them are shipped with this lib releases.

Usage

Download the last release zip package and add it to your project. Make sure all the dependencies are on the same folder that your exe.

Register the DLL using RegAsm:

%windir%\Microsoft.NET\Framework\v4.0.30319\regasm.exe /codebase PusherServerNative.dll /tlb:PusherServerNative.tlb

Add PusherServer to your unit uses clause.

PusherServer := TPusherServer.Create('app_id', 'app_key', 'secret');
PusherServer.Trigger('my-channel', 'my-event', 'my-message');

Custom Host Address

It is possible to use a custom host address:

TPusherServer.Create('app_id', 'app_key', 'secret', 'you_host.pusher.com');

The default value is api.pusherapp.com which is the pusher.com http endpoint, but you can also use it with a poxa server hosted in your own server.

Secure Connections / SSL

SSL is enabled by default. You can disable it by passing a empty option list [] to the constructor:

TPusherServer.Create('app_id', 'app_key', 'secret', '', []);

Async

To use async request you should use the TAsyncPusherServer class:

AsyncPusherServer := TAsyncPusherServer.Create('app_id', 'app_key', 'secret');
AsyncPusherServer.Trigger('my-channel', 'my-event', 'my-message');

You can use the OnError event to log the errors:

AsyncPusherServer.OnError := procedure(Error: Exception)
  begin
    Log(Error.message);
  end;

Contributing

This lib is a work in progress and any help is greatly appreciated.

Found a bug? Send us a Pull Request or create an issue, we will do our best to help.