Publish
DESCRIPTION
The publish() function is used to send a message to all subscribers of a channel. To publish a message you must first specify a valid publishKey at initialization. A successfully published message is replicated across the PubNub Real-Time Network and sent simultaneously to all subscribed clients on a channel.
Messages in transit can be secured from potential eavesdroppers with SSL/TLS by setting ssl to true during initialization.
- Multiple instance behavior: All instances are accessible throughout application via Pubnub service.
- Events: Delegated methods accept the triggerEvents option which will broadcast certain callback as an AngularJS event.
- A $pubnubChannel object that seamlessly binds a PubNub channel to a scope variable that gets updated with realtime data and allows you to interact with the channel through dedicated methods.
- A $pubnubChannelGroup object that provides an easy-to-use interface for channel groups. It stores the incoming messages in containers split by the channel and exposes an interface to directly fetch messages by channel.
You can still use the native Pubnub JavaScript SDK if you feel this will be more suitable for your situation.
INTEGRATING PUBNUB ANGULARJS SDK INTO YOUR APP
Your HTML page will include 2 key libraries:
- PubNub JavaScript SDK
- PubNub JavaScript SDK AngularJS Service
Fire
DESCRIPTION
The fire endpoint allows the client to send a message to BLOCKS Event Handlers. These messages will go directly to any Event Handlers registered on the channel that you fire to and will trigger their execution. The content of the fired request will be available for processing within the Event Handler. '
The message sent via fire() is not replicated, and so will not be received by any subscribers to the channel. The message is also not stored in history.
METHOD(S)
To set/get UUID you can use the following method(s) in AngularJS V4 SDK
Pubnub Angular service is a wrapper for PubNub JavaScript SDK that adds a few extra features to simplify Angular integrations:
- Multiple instance behavior: All instances are accessible throughout application via Pubnub service.
- Events: Delegated methods accept the triggerEvents option which will broadcast certain callback as an AngularJS event.
- A $pubnubChannel object that seamlessly binds a PubNub channel to a scope variable that gets updated with realtime data and allows you to interact with the channel through dedicated methods.
- A $pubnubChannelGroup object that provides an easy-to-use interface for channel groups. It stores the incoming messages in containers split by the channel and exposes an interface to directly fetch messages by channel.
Subscribe
DESCRIPTION
This function causes the client to create an open TCP socket to the PubNub Real-Time Network and begin listening for messages on a specified channel. To subscribe to a channel the client must send the appropriate subscribeKey at initialization.
By default a newly subscribed client will only receive messages published to the channel after the subscribe() call completes.
METHOD(S)
Unsubscribe
DESCRIPTION
When subscribed to a single channel, this function causes the client to issue a leave from the channel and close any open socket to the PubNub Network. For multiplexed channels, the specified channel(s) will be removed and the socket remains open until there are no more channels remaining in the list.
Unsubscribing from all the channel(s) and then subscribing to a new channel Y is not the same than Subscribing to the channel Y and then unsubscribing from the previously subscribe channel(s). Unsubscribing from all the channels resets the timetoken and thus, there could be some gaps in the subscription that may lead to a message loss. |
METHOD(S)
To set/get UUID you can use the following method(s) in AngularJS V4 SDK
Pubnub Angular service is a wrapper for PubNub JavaScript SDK that adds a few extra features to simplify Angular integrations:
- Multiple instance behavior: All instances are accessible throughout application via Pubnub service.
- Events: Delegated methods accept the triggerEvents option which will broadcast certain callback as an AngularJS event.
- A $pubnubChannel object that seamlessly binds a PubNub channel to a scope variable that gets updated with realtime data and allows you to interact with the channel through dedicated methods.
- A $pubnubChannelGroup object that provides an easy-to-use interface for channel groups. It stores the incoming messages in containers split by the channel and exposes an interface to directly fetch messages by channel.
Unsubscribe All
DESCRIPTION
Unsubscribe from all channels and all channel groups
METHOD(S)
unsubscribeAll()
BASIC USAGE
Pubnub.unsubscribeAll();
RETURNS
None
Listeners
DESCRIPTION
You can be notified of connectivity status, message and presence notifications via the listeners.
Listeners should be added before calling the method.
METHOD(S)
unsubscribeAll()
BASIC USAGE
Pubnub.unsubscribeAll();
RETURNS
None