ably-chat-component
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -381,5 +381,5 @@ { | ||
"ws": { | ||
"version": "5.2.2", | ||
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", | ||
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", | ||
"version": "5.2.3", | ||
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.3.tgz", | ||
"integrity": "sha512-jZArVERrMsKUatIdnLzqvcfydI85dvd/Fp1u/VOpfdDWQ4c9qWXe+VIeAbQ5FrDwciAkr+lzofXLz3Kuf26AOA==", | ||
"requires": { | ||
@@ -386,0 +386,0 @@ "async-limiter": "~1.0.0" |
@@ -29,3 +29,6 @@ import AblyBaseComponent from "./AblyBaseComponent"; | ||
super.connectedCallback(); | ||
super.subscribe('chat', 'chat-message', (message) => { | ||
const subscribeChannelAttr = this.getAttribute("data-subscribe-channel"); | ||
const subscribeChannel = subscribeChannelAttr ? subscribeChannelAttr : 'chat'; | ||
super.subscribe(subscribeChannel, 'chat-message', (message) => { | ||
this.onAblyMessageReceived(message); | ||
@@ -66,3 +69,3 @@ }); | ||
onAblyMessageReceived(message) { | ||
onAblyMessageReceived(message) { | ||
const history = this.messages.slice(-199); | ||
@@ -74,3 +77,5 @@ const updatedMessages = [...history, message]; | ||
sendChatMessage(messageText) { | ||
super.publish("chat", { name: "chat-message", data: messageText }); | ||
const publishChannelAttr = this.getAttribute("data-publish-channel"); | ||
const publishChannel = publishChannelAttr ? publishChannelAttr : 'chat'; | ||
super.publish(publishChannel, { name: "chat-message", data: messageText }); | ||
this.inputBox.value = ""; | ||
@@ -77,0 +82,0 @@ this.inputBox.focus(); |
@@ -29,3 +29,6 @@ import AblyBaseComponent from "./AblyBaseComponent.js"; | ||
super.connectedCallback(); | ||
super.subscribe('chat', 'chat-message', (message) => { | ||
const subscribeChannelAttr = this.getAttribute("data-subscribe-channel"); | ||
const subscribeChannel = subscribeChannelAttr ? subscribeChannelAttr : 'chat'; | ||
super.subscribe(subscribeChannel, 'chat-message', (message) => { | ||
this.onAblyMessageReceived(message); | ||
@@ -66,3 +69,3 @@ }); | ||
onAblyMessageReceived(message) { | ||
onAblyMessageReceived(message) { | ||
const history = this.messages.slice(-199); | ||
@@ -74,3 +77,5 @@ const updatedMessages = [...history, message]; | ||
sendChatMessage(messageText) { | ||
super.publish("chat", { name: "chat-message", data: messageText }); | ||
const publishChannelAttr = this.getAttribute("data-publish-channel"); | ||
const publishChannel = publishChannelAttr ? publishChannelAttr : 'chat'; | ||
super.publish(publishChannel, { name: "chat-message", data: messageText }); | ||
this.inputBox.value = ""; | ||
@@ -77,0 +82,0 @@ this.inputBox.focus(); |
{ | ||
"name": "ably-chat-component", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Real time chat from Ably - just add your own API key!", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -42,2 +42,4 @@ # README | ||
### Authentication | ||
While you're developing or testing, you can set your API key using `data-api-key`. | ||
@@ -64,2 +66,14 @@ | ||
### Specifying channel names | ||
You can specify which channels to use for publishing and for subscribing: | ||
```html | ||
<ably-chat data-publish-channel="chat" data-subscribe-channel="chat"></ably-chat> | ||
``` | ||
If either of these are not specified, it will default to `chat`. Usually you will want both the publish and subscribe channels to be the same, to enable clients to talk directly to one another. In some scenarios you may want to have some form of processing occur on the message before being sent to other clients. | ||
An example of this would be having a server perform filtering on messages before making them available to other clients. You could publish the messages to `chat-output`, which the server is subscribed to. The server could filter out any banned words, and then send a message to `chat-input` for all the other clients to then see the result. | ||
## Setting up token authentication | ||
@@ -66,0 +80,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39013
819
83
1