new AppService(config)
Construct a new application service.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object | Configuration for this service.
Properties
|
- Source:
Throws:
If a homeserver token is not supplied.
Methods
listen(port)
Begin listening on the specified port.
Parameters:
Name | Type | Description |
---|---|---|
port |
Number | The port to listen on. |
- Source:
onAliasQuery(alias, callback) → {Promise}
Override this method to handle alias queries.
Parameters:
Name | Type | Description |
---|---|---|
alias |
string | The queried room alias |
callback |
function | The callback to invoke when complete. |
- Source:
Returns:
A promise to resolve when complete (if callback isn't supplied)
- Type
- Promise
onUserQuery(userId, callback) → {Promise}
Override this method to handle user queries.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | The queried user ID. |
callback |
function | The callback to invoke when complete. |
- Source:
Returns:
A promise to resolve when complete (if callback isn't supplied)
- Type
- Promise
setHomeserverToken(hsToken)
Set the token that should be used to verify incoming events.
Parameters:
Name | Type | Description |
---|---|---|
hsToken |
string | The home server token |
- Source:
Events
event
An incoming Matrix JSON event.
Type:
- Object
- Source:
Example
appService.on("event", function(ev) {
console.log("ID: %s", ev.event_id);
});
http-log
An HTTP log line.
Type:
- String
- Source:
Example
appService.on("http-log", function(logLine) {
console.log(logLine);
});
type:event
An incoming Matrix JSON event, filtered by
event.type
Type:
- Object
- Source:
Example
appService.on("type:m.room.message", function(ev) {
console.log("Body: %s", ev.content.body);
});