Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
sreenivas.kaushik #1
Member since Aug 2015 · 7 posts
Group memberships: Members
Show profile · Link to this post
Subject: Authenticating the User
Hello Alex,

I have written Web API methods which will be consumed by IOS/Android clients. The IOS/Android client will supply the credentials. But each time i need to login with the user credentials and send the message. Is there any way i can login once and keep continuing sending the message instead of logging in.

Or is there any way i can persist the connection status after logging in and close the connection once  logged out and just send messages continuously.

Thanks & Regards,
Sreenivas Kaushik
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
sure, just keep the XmppClient alive in your WebApi project, and don't create a new one and Authenticate all the time.
Avatar
sreenivas.kaushik #3
Member since Aug 2015 · 7 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #1
Subject: Token on Authentication.
Hello Alex,

Thanks for your response.  As you suggested, I am keeping the connection open by setting the property KeepAlive = true, but I am still not able to send the message without logging in again.

As I mentioned in my earlier post I am using the web api's which will be consumed by client (IOS/Android) I have created two Web API's
1) AuthenticateUser (POST method) - passing the server details and user credentials
2) SendMessage (POST method) - sending the message (From, To, Subject and Body)

after authentication web API when I call the SendMessage Web API how the XMPP will identify the user since Web API's are stateless?
Could you please provide me the way to identify the user and send messages.

When the user is logged in is the XMPP server will provide any token for each user logged in (I am using the agsXMPP not Matrix) ? if so how do we get the token id and pass the same in subsequent web API requests.

Also, how the concurrency is handled in agsXMPP ? do we need to write any code to handle the same? I would be great help if you can provide some sample code for the above said ones.

Thanks & Regards,
Sreenivas Kaushik
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by sreenivas.kaushik:
after authentication web API when I call the SendMessage Web API how the XMPP will identify the user since Web API's are stateless?
Could you please provide me the way to identify the user and send messages.

When the user is logged in is the XMPP server will provide any token for each user logged in (I am using the agsXMPP not Matrix) ? if so how do we get the token id and pass the same in subsequent web API requests.

you need no create a unique ID for every conenction and return it to your client. Or let the client provide the unique id with every request. In your WebApi you need to hold a collection of XMPP connections with their unique ids. When you get a new API request get the id, find the connection and execute the message send on this connection.
The id could be also the unique id of the XMPP stream, or the full jid of the user.

Quote by sreenivas.kaushik:
Also, how the concurrency is handled in agsXMPP ? do we need to write any code to handle the same? I would be great help if you can provide some sample code for the above said ones.

It should work all fine out of the box.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS