neoPusher
Basic plugin for real time communication using Pusher channels.
More information about Pusher Channels:
https://pusher.com/channels
Sample app:
https://visualneo.com/tutorials/neochat
Description
The neoPusher plugin for VisualNEO Web enables real-time communication using Pusher Channels, allowing applications to send and receive live updates. This plugin is ideal for building interactive features like live chat, notifications, or collaborative tools within web apps. Here’s an overview of its key functionalities and practical applications:
Initializing Pusher Communication
The neoPusherInitialize command sets up the Pusher service with an API key, cluster, server URL, and debug mode.
- Command: neoPusherInitialize
- Syntax: neoPusherInitialize "apiKey" "cluster" "theUrl" theMode
- apiKey: Pusher API key.
- cluster: Pusher server cluster (e.g., eu).
- theUrl: URL to the neoPusher PHP script on the server.
- theMode: Debug mode (set to true for console logs).
Example:
neoPusherInitialize "myApiKey" "eu" "https://mydomain.com/pusher/index.php" true
This command initializes Pusher communication, setting up real-time event handling.
Subscribing to Channels and Events
The neoPusherSubscribe command subscribes to a public channel and binds to events, sending updates to a specified subroutine.
- Command: neoPusherSubscribe
- Syntax: neoPusherSubscribe "theChannel" "theEvent" theSub
- theChannel: Name of the channel to subscribe to.
- theEvent: Name of the event to listen for.
- theSub: Subroutine to handle incoming messages.
Example:
neoPusherSubscribe "notifications" "newMessage" "onNewMessage"
This listens for the newMessage event on the notifications channel, triggering the onNewMessage subroutine.
Sending Messages to Channels
The neoPusherSend command sends messages to a specified channel and event, broadcasting updates to all subscribers.
- Command: neoPusherSend
- Syntax: neoPusherSend "theChannel" "theEvent" [theData] successSubroutine errorSubroutine
- theChannel: Target channel.
- theEvent: Event name.
- theData: Data to send, in JSON or variable format.
- successSubroutine: Callback for successful send.
- errorSubroutine: Callback for send failure.
Unsubscribing and Disconnecting
To stop receiving updates, use neoPusherUnsubscribe, which removes the app from a channel and closes the connection.
- Command: neoPusherUnsubscribe
- Syntax: neoPusherUnsubscribe "theChannel"
Practical Applications
The neoPusher plugin is ideal for:
- Live Chat Systems: Enabling real-time chat in applications.
- Notifications: Sending alerts or updates to users instantly.
- Collaborative Tools: Supporting shared documents or live collaboration features.
This plugin’s real-time communication capabilities make it a powerful choice for interactive, live-updating web applications.
neoPusherInitialize
|
Purpose: |
Initialize Pusher communication |
|
Category: |
neoPusher |
|
Syntax: |
neoPusherInitialize "apiKey" "cluster" "theUrl" theMode
apiKey API key cluster Cluster (ie: eu) theUrl Server URL (neoPusher php script. ie: https://mydomain.com/pusher/index.php) theMode Debug mode (if true will send aditional data to the Console) |
neoPusherSubscribe
|
Purpose: |
Subscribe to a public channel and event, sending each new message to a subroutine. |
|
Category: |
neoPusher |
|
Syntax: |
neoPusherSubscribe "theChannel" "theEvent" theSub
theChannel Channel name theEvent Event name theSub Subroutine to execute whenever a new message arrives |
neoPusherUnsubscribe
|
Purpose: |
Unsubscribe from a channel and closes the connection. |
|
Category: |
neoPusher |
|
Syntax: |
neoPusherUnsubscribe "theChannel"
theChannel Channel name |
neoPusherSend
|
Purpose: |
Send a message to an channel event. |
|
Category: |
neoPusher |
|
Syntax: |
neoPusherSend "theChannel" "theEvent" [theData] successSubroutine errorSubroutine
theChannel Channel name theEvent Event name theData Data variable object to send successSubroutine Successs callback subroutine (optional) errorSubroutine Error callback subroutine (optional) |
Created with the Personal Edition of HelpNDoc: Make Documentation a Breeze with a Help Authoring Tool