marceloverdijk / restfbmessenger

RestFB Messenger
Apache License 2.0
22 stars 15 forks source link

Consider publishing an appcontext event instead of making people implement an interface for callbacks #4

Open marceloverdijk opened 7 years ago

marceloverdijk commented 7 years ago

As discussed with @joshlong on Twitter it might interesting to publishing appcontext events instead of making people implement an interface for callbacks.

(FacebookMessageEvent.class) void onMessage (FacebookMessageEvent evt) {..}

Maybe a restfbmessenger-spring module can be introduced with a CallbackHandler adapter that publishes the appcontext events. Users can then choose to implement their own CallbackHandler or use the adapter and use the Spring events.

marceloverdijk commented 7 years ago

One drawback of using the appcontext events is that is probably more complicated to differentiate evens from multiple chatbots.

E.g. in a single webapp I could add multiple webhook endpoints for various chatbots. In the current design each webhook endpoint (multiple WebhookServlets with their own mapping) has its own CallbackHandler, so the CallbackHandler is implemented specifically for a chatbot. When using the appcontext events will not be able the origin chatbot. @joshlong do you maybe have an idea?