Skip to content

Commit b669afd

Browse files
authored
angularjs support agent chat example
1 parent 4fabcb1 commit b669afd

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

readme.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,43 @@ chat.controller( 'chat', [ 'Messages', '$scope', function( Messages, $scope ) {
8686
</div>
8787
</div>
8888
```
89+
### Set User ID
90+
```javascript
91+
Messages.user({ id: MY_USER_ID, name : sillyname() });
92+
```
93+
### Send to User
94+
```javascript
95+
Messages.send({ to: target_user_id, data : message_body });
96+
```
97+
98+
If you want random user id's that are transient... you can publish the LIST of users to the "global" channel and receive each user who has come online.
8999

90100

101+
# AngularJS Support Desk Chat Agent Example
102+
103+
### Vistor
104+
```javascript
105+
// this is a user comes online
106+
// send a notice to the support agent.
107+
Messages.send({ to: "support-agent", data : { visitor : true } });
108+
```
109+
110+
### Support Agent
111+
```javascript
112+
113+
// support agent code
114+
$scope.visitors = [];
115+
116+
// they have a "support-agent" ID.
117+
Messages.user({ id: "support-agent", name : "Support Agent" });
118+
119+
// support agent seeing a new visitor
120+
Messages.receive(function(msg){
121+
if (msg.data.visitor) $scope.visitors.push(msg.user.id);
122+
console.log(msg);
123+
});
124+
```
125+
91126
## AngularJS Chat Resources
92127

93128
- [AngularJS Chat Website](http://angular.chat)

0 commit comments

Comments
 (0)