Hi, Thanks for your patch! I'll take a look at it soon. In the meantime do you want to provide a Pull Request with a demo of the new functionality for https://github.com/martin-g/blogs/tree/master/wicket6-native-websockets ?
On Mon, Oct 22, 2012 at 10:37 PM, Mikko Tiihonen <[email protected]> wrote: > Hi, > > Few weeks ago I created a patch that provides a way to push convert external > events into wicket events that allow components to update themselves and > push the results back to all browsers that have open websocket connection to > the wicket application. > > I put the first version of the patch here > https://issues.apache.org/jira/browse/WICKET-4832 > > The API is pretty simple: > > Pass reference to wicket application to any non-wicket thread: > WebSocketPushBroadcaster pusher = new WebSocketPushBroadcaster(); > pusher.broadcastAll(applicationRef, new ExternalSourcePush("pass relevant > data to components")); > where > static class ExternalSourcePush implements IWebSocketPushMessage { ... } > > The wicket components that have active websocket connections will then > receive a normal wicket websocket event: > > public void onEvent(IEvent<?> event) { > if (event.getPayload() instanceof WebSocketPushPayload) { > WebSocketPushPayload wsEvent = (WebSocketPushPayload) > event.getPayload(); > ExternalSourcePush data = (ExternalSourcePush) wsEvent.getMessage() > > label.setDefaultModelObject(data.message); > wsEvent.getHandler().add(label); > } > } > > Alternatively you can just pass a specific wicket websocket > ConnectionMessage and use that as a context to send the events to. > > --- > TODO items: > > 1) I was trying to add a Class<? extends Page> filter to the broadcastAll > first so that I could get only the relevant websocket connections from the > registry and not all pages need to be touched. In that case websocket > registry would need to be updated to keep track of also page classes, not > just their pageId, or is there a easy way to map from pageId to page class? > Or do you think the broadcastAll that loops through all active websocket > connections is not too heavy? > > 2) testing framework > > -Mikko -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com
