Hi Martin,

Many thanks for feedback. I will file a ticket.


> Please file a ticket.
> TextMessage and BinaryMessage can be improved.
> I have to see whether IWebSocketConnection can be improved too.
>

I see  AbstractWebSocketConnection contains AbstractWebSocketProcessor and
this one a pageId. Meanwhile I can try to roll my own implementation to
cover use case.

But due to API changes this could be done only for Wicket 9.x.
>

I understand. We are still on 7.x... One more argument to push for going
8.x and then 9.x.

Maybe one possibility to make this more configurable is allow to register
at "application level" some factory for IWebSocketConnections and/or
TextMessages? So, no need to break this on 7.x, 8.x? I don't know if this
makes sense at all? I see AbstractWebSocketProcessor contains both
Application and pageId.


>
> On Wed, Apr 3, 2019 at 4:19 PM Ernesto Reinaldo Barreiro <
> reier...@gmail.com>
> wrote:
>
> > I meant my "question"
> >
> > On Wed, Apr 3, 2019 at 4:18 PM Ernesto Reinaldo Barreiro <
> > reier...@gmail.com>
> > wrote:
> >
> > > Hi,
> > >
> > > Thanks for your answer. Yes my answer was more on the spirit if there
> is
> > > something already available and ready to use.... Or if it makes sense
> to
> > > have this by default at interface level.
> > >
> > > On Wed, Apr 3, 2019 at 3:37 PM Maxim Solodovnik <solomax...@gmail.com>
> > > wrote:
> > >
> > >> Hello Ernesto,
> > >>
> > >> We also have code to send websocket messages "to others"
> > >> I do store active client list (each page/tab is client)
> > >> Every client stores pageId and sessionId
> > >>
> > >> Then I do filtering on pageId+sessionId
> > >>
> > >> This seems to work as expected
> > >>
> > >> On Wed, 3 Apr 2019 at 18:18, Ernesto Reinaldo Barreiro
> > >> <reier...@gmail.com> wrote:
> > >> >
> > >> > Hi,
> > >> >
> > >> > I have the following use case.
> > >> >
> > >> > 1- One browser tab sends a text message
> > >> > 2- Other browser tabs should receive message (but emitting tab not).
> > >> >
> > >> > I have done
> > >> >
> > >> > add(*new *WebSocketBehavior() {
> > >> > @Override
> > >> > *protected void *onMessage(WebSocketRequestHandler handler,
> > TextMessage
> > >> > message) {
> > >> > sendNotificationToSession(....)
> > >> > }
> > >> > });
> > >> >
> > >> >
> > >> >
> > >> > *public void *sendNotificationToSession(String sessionId) {
> > >> > *if *(com.rometools.utils.Strings.*isEmpty*(sessionId)) {
> > >> > *throw new *IllegalArgumentException(*"sessionId cannot be empty"*);
> > >> > }
> > >> > Application application = Application.*get*(KmsContext.*APP_NAME*);
> > >> >
> > >>
> >
> privateSendNotificationTo(getRegistry(application).getConnections(application,
> > >> > sessionId));
> > >> > }
> > >> >
> > >> >
> > >> > *private void
> > >> *privateSendNotificationTo(Collection<IWebSocketConnection>
> > >> > webSocketConnections) {
> > >> > String message = toJSON();
> > >> > *for*(IWebSocketConnection connection : webSocketConnections) {
> > >> > *if *(connection.isOpen()) {
> > >> > *try *{
> > >> > connection.sendMessage(message);
> > >> > } *catch *(IOException e) {
> > >> > *log*.error(*"Could not send notification"*, e);
> > >> > *//$NON-NLS-1$ *}
> > >> > }
> > >> > }
> > >> > }
> > >> >
> > >> >
> > >> > I see some classes like
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> > */**  * A base message for all messages with information about the
> > >> client
> > >> >  */ **public abstract class *AbstractClientMessage *implements *
> > >> > IWebSocketMessage
> > >> > {
> > >> > *private final *String *applicationName*;
> > >> > *private final *String *sessionId*;
> > >> > *private final *IKey *key*;
> > >> >
> > >> > *public *AbstractClientMessage(Application application, String
> > >> sessionId,
> > >> > IKey key)
> > >> > {
> > >> > *this*.*applicationName *= Args.*notNull*(application,
> *"application"*
> > >> > ).getName();
> > >> > *this*.*sessionId *= Args.*notNull*(sessionId, *"sessionId"*);
> > >> > *this*.*key *= Args.*notNull*(key, *"key"*);
> > >> > }
> > >> >
> > >> > *public *Application getApplication()
> > >> > {
> > >> > *return *Application.*get*(*applicationName*);
> > >> > }
> > >> >
> > >> > *public *String getSessionId()
> > >> > {
> > >> > *return **sessionId*;
> > >> > }
> > >> >
> > >> > *public *IKey getKey()
> > >> > {
> > >> > *return **key*;
> > >> > }
> > >> >
> > >> > }
> > >> >
> > >> >
> > >> > provide IKey as "discriminator" of sending page. But this is neither
> > >> part
> > >> > of IWebSocketMessage nor it is part of IWebSocketConnection... So, I
> > >> don't
> > >> > really know to use to exclude the emitting page. This clearly would
> be
> > >> > possible if both IWebSocketMessage and IWebSocketConnection have a
> > IKey
> > >> > getPageKey();
> > >> >
> > >> >
> > >> > Is there a way to do this? Am I missing some essential part?
> > >> >
> > >> >
> > >> > --
> > >> > Regards - Ernesto Reinaldo Barreiro
> > >>
> > >>
> > >>
> > >> --
> > >> WBR
> > >> Maxim aka solomax
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > >> For additional commands, e-mail: users-h...@wicket.apache.org
> > >>
> > >>
> > >
> > > --
> > > Regards - Ernesto Reinaldo Barreiro
> > >
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> >
>


-- 
Regards - Ernesto Reinaldo Barreiro

Reply via email to