Logo

0x5a.live

for different kinds of informations and explorations.

GitHub - edgurgel/pusher: Elixir library to access the Pusher REST API.

Elixir library to access the Pusher REST API. Contribute to edgurgel/pusher development by creating an account on GitHub.

Visit SiteGitHub - edgurgel/pusher: Elixir library to access the Pusher REST API.

GitHub - edgurgel/pusher: Elixir library to access the Pusher REST API.

Elixir library to access the Pusher REST API. Contribute to edgurgel/pusher development by creating an account on GitHub.

Powered by 0x5a.live ๐Ÿ’—

Pusher Build Status Hex pm

Description

Elixir library to access the Pusher REST API.

Usage

Rest client

Define your Pusher.Client

ciient = %Pusher.Client{app_id: "app_id", app_key: "app_key", secret: "my_secret"}
ciient = %Pusher.Client{endpoint: "https://my_custom_pusher:8080", app_id: "app_id", app_key: "app_key", secret: "my_secret"}
Pusher.trigger(client, "message", %{ text: "Hello!" }, "chat-channel")

To get occupied channels:

Pusher.channels(client)

To get users connected to a presence channel

Pusher.users(client, "presence-demo")

Websocket client

Usage

iex> {:ok, pid} = Pusher.WS.start_link("ws://localhost:8080", "app_key", "secret", stream_to: self)
{:ok, #PID<0.134.0>}
iex> Pusher.WS.subscribe!(pid, "channel")
:ok
iex> Pusher.WS.subscribe!(pid, "presence-channel", %PusherClient.User{id: "123", info: %{a: "b"}})
:ok
# self will receive messages like this:
%{channel: nil,
  data: %{"activity_timeout" => 120,
    "socket_id" => "b388664a-3278-11e4-90df-7831c1bf9520"},
  event: "pusher:connection_established"}

%{channel: "channel", data: %{}, event: "pusher:subscription_succeeded"}

That's it!

You can disconnect too:

iex> Pusher.WS.disconnect!(pid)
:stop

Elixir Resources

are all listed below.

Resources

listed to get explored on!!

Made with โค๏ธ

to provide different kinds of informations and resources.