Skip to content

Commit

Permalink
Merge pull request #507 from IanMayo/improve-pubsub0guidance
Browse files Browse the repository at this point in the history
Introduce samples of creating and deleting a node
  • Loading branch information
legastero authored Oct 24, 2024
2 parents 829bdbf + 08fde9c commit 8c7435b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions docs/Using_PubSub.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ import MyContentPlugin from 'mycontentplugin';
client.use(MyContentPlugin);
```

## 2. Publishing our new content
## 2. Creating our new node

On some servers (OpenFire) a node much be created before it can be published to.

```javascript
client.create('pubsub.example.com', 'ournode');
```

## 3. Publishing our new content

```javascript
client.publish('pubsub.example.com', 'ournode', {
Expand All @@ -56,7 +64,7 @@ client.publish('pubsub.example.com', 'ournode', {
});
```

## 3. Subscribing to our content
## 4. Subscribing to our content

```javascript
client.subscribeToNode('pubsub.example.com', 'ournode');
Expand All @@ -71,7 +79,7 @@ client.subscribeToNode('pubsub.example.com', {
});
```

## 4. Receiving publish events
## 5. Receiving publish events

```javascript
client.on('pubsub:published', msg => {
Expand All @@ -96,7 +104,7 @@ client.subscribeToNode('pubsub.example.com', {
});
```

## 5. Unsubscribing
## 6. Unsubscribing

```javascript
client.unsubscribeFromNode('pubsub.example.com', 'ournode');
Expand All @@ -110,3 +118,10 @@ client.unsubscribeFromNode('pubsub.example.com', {
useBareJID: true
});
```

## 7. Deleting our node


```javascript
client.deleteNode('pubsub.example.com', 'ournode');
```

0 comments on commit 8c7435b

Please sign in to comment.