How to create chat with API Gateway using sockets [JAVA] - java

I am trying to create small aplication with CLI, API and microservices. I've already created a few needed microservices eg. login, registration. Now, I am focused on creating chat. I have no clue how to corectly comunicate client (CLI) with API(server that choose mode that user send) and API with microservice. I work with G4G code trying to convert it to my purposes: Server, Client. I am adding simple picture of my project.
Simple example:
Another more detailed but in native language

Related

How to implement a messaging service in react-native with a java backend?

I am creating an app using React-Native for the front-end, Java for the back-end and PostgreSQL for the database.
One feature of this app is to allow users to add each other as friends and instant message them - just like other social networks. At the moment, security is not a priority but I don't want to create something that I will have to completely redo when I do have to make it secure!
The goal here is to give each user the ability to send/receive messages to/from their friends. They also need to be able to view the message history with each contact.
I just need some advice on the following points to get me going as I haven't gotten very far on my own:
How should I send messages from the front-end, to the Java server and then to the receiver? This will involve the app having to listen for new messages so would the Socket.IO library be the way to go for this?
How I should store the messages in the database? E.g. have a table for messages with user_ids to be used for retrieval?
I should point out that I am very new to React-Native, databases and networking so I am finding this very challenging!
I will massively appreciate any help and any examples would be fantastic!
You should use WebSocket on the server. Spring supports it
Here's a tutorial I wrote about sending messages from PostgreSQL to the browser using WebSocket, which isn't exactly what you're going to do, but can hopefully get you started:
http://blog.databasepatterns.com/2014/04/postgresql-nofify-websocket-spring-mvc.html

WebClient SparkWeb vs JwChat for openfire server (XMPP)

I am newbie in XMPP. I am trying to create a multi user chat using in a spring framework project with xmpp. I am using openfire as chat server. I am very confused for what client should i use for chat. I have gone through some like SparkWeb, JwChat and strophej. But can't figure out for which one should i go?

Integrate a finished web service in a Android application

I don't know if the correct term is "integrate" or "connect" a finished web service in a android application. I mean,
Is there any possibility to "integrate" a finished RESTful Web Service in a Android application, which I have not developed, yet.?
Otherwise,
Are there some steps to develop a RESTful web service which I need to use from a Android application?
The last question is asked because I don't know if the first step is to finish my RESTful Web Service and then integrate it in my android application or or developing the RESTful web service and the android application at the same time.
In any case, how I can do it well? I need help to organise my mind
You will need three things:
Client(your app)
Server
Database
Lets say you have to create a login service for your app. Then your steps should be like given below:
Create a login form with android UI.
Get username and password from Edit Texts in strings.
Send these credentials to server(via http reqest).
At client side read response from url via input stream.
At the server side, use a server side technology in which you are familiar with.(If you are not familiar with any server side tech. I strongly recommend you php.)
Select/update/compare (Whatever you want) in data base and return response as a json string.
You can use server on your system. I suggest to use XAMPP(cross platform apache mysql php perl). As its name says, it includes server+database+php (its local). It will create a local apache server on your machine.
Follow this : XAMPP Tutorial , Working with XAMPP
Here are some nice tutorials of web services with android:
How to connect Android with PHP, MySQL
Using Database from an Android Application

Sending and receiving data from an Android application to a web hosted Java application

I've been looking around all morning, and can't seem to figure this one out. I know it's not as complicated as I think it is, and all I need is just some pointers to the right direction.
I have an Android application that takes some user input, sends it to a Java application over the web, and then receives some output based on the input.
My Android and Java applications are ready, but how do I go about sending and receiving the data over the web? I understand that I'll be sending and receiving HTTP requests, but my problem is where I'll be sending them and receiving them from. Do I host my Java application on a Servlet like Tomcat, or do I use something like OpenShift to host my application for me?
I have no trouble with sending some HTTP request from my Android application to the web and receiving some output back, but my problem is that my web service needs to use a Java library to process the input and generate the output. I'm just not sure how I'm supposed to get this data to and from this Java library that needs to be hosted on the web.
I hope my question makes any sense.
EDIT: Perhaps I wasn't clear with what exactly I need help with. I do realize that the architecture I use doesn't really make any difference, but the problem I have is with how I'm supposed to use this architecture.
Let's say I have a registered domain name that I can easily send to and receive data from using my Android application - no trouble with that. But how am I supposed to integrate my Java library with this server? Do I just create an applet and put it on my server? Does my web host even allow Java applets to run?
I guess my question is how I'm supposed to get through the "barrier" between my HTTP request / transport layer protocol and my Java application.
Server architecture usually does not matter. You can use Java, NodeJs, Rails, Python, .NET, etc. You just need an endpoint that accepts a HTTP POST/PUT/GET/DELETE/PATCH verb.
This is more a question of "how do I set up a server to accept input" and its a very large topic in itself. I would advise you look at PAAS solutions like:
Parse.com
Kinvey.com
You can use their tools to build a solution fairly quickly. If you need something custom you'll need to build your backend in the language of choice and host it online via AWS, Google Cloud, Heroku, a VPS or something similar.

program-o for android chat bot application

I am developing android chatbot application using program-o. I have program-o running on my localhost. I went through program-o documentation but still, I'm not able to understand what changes I need make to enable the communication between my Android app and program-o server.
Write a php code to use program-o api.
Take the chat input from GET/POST parameters.
Use that input to get the output from program-o.
Parse that into json or any other format you like and print it.
Host that php file on a web server.
Now make an HTTP connection from android app. Give the input as parameters and parse the output received.
You have to create a LAMP server and run an instance of Program o
Json / xml rest api will interface will android app
You must use async task runner,httpresponse , and all.

Categories