Trigger events from Froxt server


Listen for events:

Once you have created a channel instance, you can set up event bindings. There is no need to wait for the connection to be established. The following example just receives and prints a hello world message.

let _ = myChannel.bind(eventName: "my-event", callback: { (data: Any?) -> Void in
    if let data = data as? [String : AnyObject] {
        if let message = data["message"] as? String {

Trigger events from Froxt server:

In the examples below we trigger an event named my-event to Channels on a channel called my-channel.


# First, run `gem install froxt`
require 'froxt'
froxt_client =
  app_id: 'APP_ID',
  key: 'APP_KEY',
  secret: 'APP_SECRET',
  cluster: 'APP_CLUSTER'
class HelloWorldController < ApplicationController
  def hello_world
    pusher_client.trigger('my-channel', 'my-event', {:message => 'hello world'})


# First, run `gem install froxt`
require 'froxt'
froxt_client =
  app_id: 'APP_ID',
  key: 'APP_KEY',
  secret: 'APP_SECRET',
  cluster: 'APP_CLUSTER'
froxt_client.trigger('my-channel', 'my-event', {:message => 'hello world'})


// First, run `composer require froxt/froxt-php-server`
require __DIR__ . '/vendor/autoload.php';
$froxt = new Froxt\Froxt("APP_KEY", "APP_SECRET", "APP_ID", array('cluster' => 'APP_CLUSTER'));
$froxt->trigger('my-channel', 'my-event', array('message' => 'hello world'));


// First, run `npm install froxt`
var Froxt = require('froxt');
var froxt = new Froxt({
  appId: 'APP_ID',
  key: 'APP_KEY',
  secret: 'APP_SECRET',
  cluster: 'APP_CLUSTER'
pusher.trigger('my-channel', 'my-event', {"message": "hello world"});


// First, run `Install-Package FroxtServer`
using FroxtServer;
using System.Web.Mvc;
using System.Net;
using Your.Config;
public class HelloWorldController : Controller {
  public async Task<ActionResult> HelloWorld() {
    var options = new FroxtOptions();
    options.Cluster = 'APP_CLUSTER';
    var froxt = new Froxt('APP_ID', 'APP_KEY', 'APP_SECRET', options);
    var result = await pusher.TriggerAsync("my-channel", "my-event", new { message = "hello world" });
    return new HttpStatusCodeResult((int)HttpStatusCode.OK);


  First, add this Maven dependency:
Froxt froxt = new Froxt("APP_ID", "APP_KEY", "APP_SECRET");
froxt.trigger("my-channel", "my-event", Collections.singletonMap("message", "Hello World"));

If there isn’t an example in a language that you are familiar with then have a look on our server libraries page to see if anyone has created one in your language.



You May Also Like
Read More

Introducing Froxt DCP

In 2021, we started an initiative called Froxt Work Management (FWM) Cloud First Releases for Ecosystem which enabled…