Project

General

Profile

Handling client disconnecting in component

Taras Panchak
Added over 2 years ago

Could you please provide some help - we developed new component:

@ public class MyComponent extends AbstractComponent { ... }@

and related to it controller:

public class DefaultMyController implements Initializable {
    private MyComponentContext;

    @Inject
    private EventBus eventBus;

    public DefaultMyController (MyComponentContext context) {
        this.context = context;
    }

    public EventBus getEventBus() {
        return eventBus;
    }

    public void setEventBus(EventBus eventBus) { this.eventBus = eventBus; }

    @Override
    public void initialize() {

        eventBus.addHandler("RoomJoin", "tigase:events:muc", (name, xmlns, event) -> {
            String room = event.getCDataStaticStr(new String[]{"RoomJoin", "room"});
            String nickname = event.getCDataStaticStr(new String[]{"RoomJoin", "nickname"});
            String jid = event.getCDataStaticStr(new String[]{"RoomJoin", "jid"});

                        //  Do something after room joining... - This works fine.

        });

And my questions are:

1) how i can handle client disconnection (component on server-side)?

2) where i can find some information about list of events which Tigase can handle?

Any help appreciated.


Replies (3)

Added by Wojciech Kapcia TigaseTeam over 2 years ago

Taras Panchak wrote:

And my questions are:

1) how i can handle client disconnection (component on server-side)?

2) where i can find some information about list of events which Tigase can handle?

  • currently there is no list of available events (generated by the default set of Tigase components)

  • currently there isn't any event related to user logging-in/logging-out - version 7.1.0 laid foundations for TCF and introduced EventBus, however more wide use is planned fro upcoming 7.2.0.

Added by Taras Panchak over 2 years ago

Thanks Wojciech for your reply.

Please explain how works this one handler - because it realy works in my component:

@eventBus.addHandler("RoomJoin", "tigase:events:muc", (name, xmlns, event) -> {

        String room = event.getCDataStaticStr(new String[]{"RoomJoin", "room"});

        String nickname = event.getCDataStaticStr(new String[]{"RoomJoin", "nickname"});

        String jid = event.getCDataStaticStr(new String[]{"RoomJoin", "jid"});

        //  Do something after room joining... - This works fine.

   });

@

Added by Wojciech Kapcia TigaseTeam over 2 years ago

It's generated in tigase.muc.modules.PresenceModuleImpl:285 - so when the event is generated all registered handlers for particular event Name and XMLNS (as in your case) will get executed.

    (1-3/3)