/**
* @module flitter-socket/templates/controller
*/
/**
* Get the contents of a new controller file with the given class name.
* @param {string} name - the name of the Controller's class
* @returns {string}
*/
module.exports = exports = (name) => {
return `const SocketController = require('flitter-socket/Controller')
class ${name} extends SocketController {
static get services() {
return [...super.services, 'app', 'output']
}
ping(transaction, socket){
this.output.debug('Sending Ping!')
transaction.status(200).message('Pinging!').send(transaction.incoming)
// Make a request to the client
this._request('test_endpoint', {hello: 'world'}, (t, ws, data) => {
this.output.debug('Got ping response!')
this.output.debug(data)
t.resolved = true
}, transaction.connection_id)
}
}
module.exports = exports = ${name}
`
}