koajs / koa.io

[MAINTAINERS WANTED] Realtime web framework combine koa and socket.io.
429 stars 51 forks source link

Emitting from a endpoint #63

Open DarrylD opened 8 years ago

DarrylD commented 8 years ago

When the client hits an endpoint, trying to do something like so

var router = require('koa-router')();

router.get('/test', function *(next) {

    //this.brodcast?

    this.body = dostuff();
})

Is this possible? Want to send messages to clients when endpoints are hit.

tunnckoCore commented 7 years ago

@DarrylD heya! Sorry for the delay.

Is this possible?

Yea, I believe you can access do this.io.broadcast, because we have this.io in the app instance.