- Multiple PubNub subscription channels for chat, color changing, dancing and bot pirate integration.
- PubNub Presence functionality & HereNow requests to get the number of connected ducks.
- PubNub Storage & Playback (history) functionality for updating UI state when connecting and reconnecting. History also used to show recent messages in the chat channel on request.
- Handling PubNub network events.
- Using PubNub Functions for:
- "Before Publish" function to simulate bad word filtering and translation.
- "After Publish" function and PubNub's KV Store to track recent actions. With the correct set of actions, the functions sends a message that makes all of the ducks dance and wiggle.
- "After Publish" function to simulate extra duck chat inhabitants.
- Built-in access to a log of recent incoming and outgoing PubNub messages to understand how changes happening in the interface are implemented.
- Use of aria-live sections to support better accessibility on chat changes.
Try it! Let out your pirate duck.
The demo is specifically designed to be used in demo environments. Use the following as a guide.
- This is the latest message sent on the
ducks.talk
channel. Name, time and content are all represented. - The talk bubble opens an overlay and calls the
history
api for the last 20 messages in theducks.talk
channel. - The duck is always the latest color message sent in the
ducks.color
channel. Shows how a chat room can turn into a connected experience, easily adding functionality not normally found in standard 'chat' solutions. - Send a message to the
ducks.talk
channel. Sends the message up to the PubNub service and then the application receives that message and shows it in1.
and10.
. - Clicking the
message
word opens an overlay to allow users to send custom messages to theducks.talk
channel. - Send a color message to the
ducks.color
channel. Sends the message up to the PubNub service. The application receives that message and shows it in3.
and11.
. - Clicking the
change color
words opens an overlay to allow users to send custom color messages to theducks.color
channel. - Using PubNub's presence service on the
ducks.talk
channel, the application knows how many other ducks are connected. - Each instance of the application generates a random duck name every time it is loaded. This is used as the UUID when interacting with the PubNub API.
- The last
ducks.talk
message is listed here. aria-polite is used to announce the text change when using screen readers. - The last
ducks.color
message is listed here. aria-polite is used to announce the color change when using screen readers. - The last dance, the last message sent on the
ducks.dance
channel is listed here. - Clicking the "Show PubNub message log" will show the last 30 messages sent to and recieved from the PubNub service, in realtime. Use this to show developers how the JSON payload is packaged and displayed to the interface.
"Woof!"
is considered a bad word in the pirate duck language. As such, it is always changed to"Quack!"
through a very simple "Before Publish" PubNub Function. Use this to describe how Functions can interact with the content flowing through the network.
In addition to all of that, there is an "After Publish" PubNub function that listens to all messages posted to ducks.talk
and ducks.color
. The last three messages are stored in the KV Store. If the three are matched against a 'magic set', the function sends a 'dance' message to the ducks.dance
channel. The dance aligns to one of the animations from animate.css. The duck will dance in response. Try Yellow
, Red
, Blue
or "Quack!"
, "Quack!"
,"Quack!"
. The full set of magic sequences can be found in the function-dance.js
file in PubNubFunctions/duck-dance.
- Sign up for PubNub
-
Create a new App or use one that is created for you when you sign up.
-
Install the
Publish key
andSubscribe key
from the administration interface into thepubnub-keys.js
files asPUBNUB_PUBLISH_K
andPUBNUB_SUBSCRIBE_K
.
-
Turn on Presence, Storage & Playback and PubNub Functions in the admin portal. (Keys -> (name of your application) -> Application add-ons) Remember to Save Changes in the lower right corner.
-
Optional: Follow the instructions in
PubNubFunctions/filter-and-translate/README.md
to install the pirate duck text chat filter and translation "before publish" PubNub Function. -
Optional: Follow the instructions in
PubNubFunctions/duck-dance/README.md
to install the pirate duck dance "after publish" PubNub Function. -
Optional: Follow the instructions in
PubNubFunctions/duck-bots/README.md
to install the pirate duck bots "after publish" PubNub Function. -
Have fun.
Pirate Duck Chat is maintained by Mark Williams
Software is licensed under MIT (see license file).
The readme files are Copyright 2019 Mark D. F. Williams
- Uses "Duck" by Nikita Kozin from the Noun Project
- Uses "Pirate" by Andrejs Kirma, LV from the Noun Project
- Thanks to animate.css by Daniel Eden for making it easy to make the ducks dance.
- Some True Type fonts are used from Google Fonts.
This readme © 2019 Mark D. F. Williams All Rights Reserved.