powered by Jive Software

How to implement one-to-one message incoming listener in android using SSE rest api

Hi… this is my first topic on this forum, so please correct me if anything I’m gonna say is wrong.

I am developing an android chat app using https://github.com/igniterealtime/Openfire-Chat . here are what I already achieved:

  1. create basic authentication, login using username & password and access rest api “/login”
  2. after login, I got streamid
  3. then I display chat history with another user with rest api “GET /chat/messages?to=x”
  4. I can send message to user x with rest api “POST /chat/{streamid}/messages/x@domain”

Now I want to receive message when “user x” send a message to that android chat app. I read this can be achieved. some info I found at above link on section how to use openfire-chat :

Asynchronous push events from the server for handling chat, groupchat audio, video and telephone conversations can be received as SSE events or as JSON messages over a SIP connection if the openfire ofswitch plugin is enabled [1] and the user has a SIP websocket connection opened [2]. See ofswitch plugin for more details [3].

Another info is from the same page, at above link on section how to send & receive one-on-one message :

To receive a one-to-one chat message, ensure you have an SSE connection created on the web client [4] and a handler coded to handle the expected JSON messages [5]. See https://your_server:7443/apps/sse/index.html [6] for an example on how to do this.

I already checked on the built-in rest api swagger, there is a rest api link to handle sse that is “GET /event/source”

but after I clicked “Try it out!” button, I got response code: 404 like this:

the request url is where is my localhost ipv4.

there are steps to implement one-to-one message incoming listener in android, but I cant code it into my android app because I dont find any documentation about the detail.

My questions are:

a. I already installed ofswitch from github(dot)com/Traderlynk/Etherlynk-Server to satisfy [1], but I dont know how to check if it is enabled or not?.

b. I really dont find any documentation or info about [2]. how I can open SIP websocket connection for a user?

c. Where I can find details about ofswitch plugin [3] ?

d. How to create SSE connection on (android) client [4] ?

e. How to code handler to handle incoming message [5], or incoming listener in android?

f. When I open https://your_server:7443/apps/sse/index.html , I see: HTTP ERROR 503. I assume I need to install a plugin or set something for it to work. Where I can find the detail for [6] ?

I made many bold text, just to make my points clearer. Please help me… I really meet a dead end about this. For any help, thank you :pray: