how to create chat(websocket) server on google cloud platform - google-app-engine

I already working on AppEngine which is my android backend but I have to create chat system for my app so I cannot figure out how to do that.
I'm using spring boot
please help. sorry for any kind of mistake.

You can use google compute engine on google cloud to write down your WebSocket server.
Also, you can use apache thrift for a seamless design of communication protocol between different language. It saves lots of repeated effort while designing communication protocol.
From Quora
There's a lot of repeated work you have to do when you're writing a server - primarily designing a protocol and writing code to serialize and deserialize messages on the protocol, but also dealing with sockets and managing concurrency, and writing clients in many languages. Thrift automatically does all of this, given a description of the functions you want to expose from your server to clients. It's also useful for serializing data on disk or into shared memory (where many of the same problems come up).

Related

How to build a cloud application and keep portability intact?

Please check the answer and comments of my previous question in order to get a better understanding of my situation. If I use Google DataStore on AppEngine, my application will be tightly coupled and hence loose portability.
I'm working on Android and will be using backend which will reside in the cloud. I need client-cloud communication. How do I build an application maintaining portability. What design patterns, architectural patterns should I be using?
Should I use a broker pattern? I'm perplexed.
Google AppEngine provides JPA based interfaces for its datastore. As long as you are writing your code using JPA APIs, it will be easy to port the same to other datastores (Hibernate for example also implements JPA).
I would ensure that the vendor specific code doesn't percolate beyond a thin layer that sits just above the vendor's APIs. That would ensure that when I have to move to a different vendor, I know exactly which part of code would be impacted.
It u really want to avoid portability issues use google cloud sql instead. If u use the datastore unless its a trivial strucfure you sill not be able to trivially port it eve if you use pure jpa/jdo, because those were really not meant for nosql. Google has particularifies with indexes etc.
Of course sql is more expensive and has size limits
In order to maintain portability for my application, I've chosen Restlet, which offers Restful web apis, over endpoints. Restlet would help me to communicate between server and client.
Moreover, it would not get my application locked in to a particular vendor.

Application backend and networking?

I'm not sure if the title I used is good, but hopefully my question will be better.
I have an java application that tracks data on PennyAuction sites(such as beezid.com), and will eventually upload all of the data to a database. Clients will download a java application and run it on their local machine, but this local machine application will have to be able to access the database and obtain all of the data.
All I have ever done is java applications programming, so this is all very new to me. Can anybody help me with a solution that will be able to accomplish this?
This is all I can think of:
Server that will run Backend application 24/7, and use JDBC to upload data to database.
Separate server for database alone.
I have no idea how the client application should connect to the database though.
Any help/links to tutorials on stuff like this would be appreciated.
You could actually let your clients connect to the database directly if the database is on a public IP.
An architecurally much better way of doing this is with webservices. This would make your system much more safe, robust and scalable.
Web services are client and server applications that communicate over the World Wide Web’s (WWW) HyperText Transfer Protocol (HTTP). As described by the World Wide Web Consortium (W3C), web services provide a standard means of interoperating between software applications running on a variety of platforms and frameworks. Web services are characterized by their great interoperability and extensibility, as well as their machine-processable descriptions, thanks to the use of XML. Web services can be combined in a loosely coupled way to achieve complex operations. Programs providing simple services can interact with each other to deliver sophisticated added-value services.

Http-TCP/IP proxy programming

I need to create a server that will receive an encrypted/signed message in form of a http request (Google App Engine), decrypt it/check the signature, and send it over a TCP/IP connection (Bitcoin network). Moreover, it will need to do the same in reverse - receive TCP/IP messages, encrypt/sign them, and send them as a http request. I'm planning to put the server on EC2.
I don't have too much experience with these things, so I'd like to ask - what is the easiest programming language to create something like that in, and what libraries would you recommend for the required usability?
If this is your first time doing something like this, I would suggest keeping it simple. Do you really need part of your system running on App Engine and part on EC2? For a newbie developer I would suggest sticking to one or the other. If you really need TCP/IP sockets, this will mean EC2 only. App Engine can not do arbitrary TCP/IP networking - you can only communicate via http and https. (note that I am unfamiliar with bitcoin's details - perhaps it can operate just fine over https)
When it comes to picking a programming language and web framework, if you don't have any experience at all yet, you might want to find out what the best bitcoin libraries are written in, and start there.

Distributed application architecture

We are building an application that will have clients installed in many sites. Each client work on its own, has its own database and workflows. However, each client has to submit some data to the main application installed at a central position. The application at a central location must receive updates (e.g stock levels) from the distributed units. All applications are done in Java. Which is the best way/technology of sending the updates from the distributed units to the central application? JMS, jdbc, ...?
I'm going to assume that the servers at client sites have network access, and that you are able to configure the central server so that other clients can connect to it. This could either be over the internet or an internal WAN.
In this case, it's simply a case of finding a mechanism to submit some correctly formatted data, which is received and handled by the central server. This gives you a large number of options, I'm going to list just a few:
Create a web service with something like Apache Axis
Use an ESB - something like Mule or JBoss
Use a simple web Servlet on the server, and submit data using HTTP POST. You could use a simple embeddable Java web server like Jetty to do this.
Use a messaging protocol like Kryonet or Google's protocol buffers
Use a more general network application framework such as Netty
All of these will work, so it really depends on working out which is the best fit for your architecture. I suspect the simplest would be something like Kryonet, the most comprehensive would probably be something like a full JBoss ESB/application server stack.

Server Programming - Simple Multiplayer Game - Which protocol and technologies?

I have a year's experience writing client code but none with server stuff. I want to restrain the question a bit so I'll simplify what I'm trying to achieve.
I want to write server code such that two clients (Browser or iPhone / Android) can connect, when two player have connected they see a timer count down to zero. The clock would be synchronize on the server and the clients would be uniquely identifiable.
The trouble here is with the word connect, what do people use for multiplayer games? Open a TCP socket for two way communications? You can tell I'm not really sure what I'm talking about. I was hoping to use AppEngine but I'm not sure if it's suitable as it's request based.
I have some experience with Java and although Erlang sounds like the best choice this is something I just want to play with and push out fast so Java would be easier. I just need to know the best way to connect players etc.
Thanks,
Gav
I suggest we regard desktop and mobile systems as equal clients. What options are then?
You write a socket server which will accept connections from clients. But then you need to write some socket client as well, even 2x - for a desktop and for a mobile OS. And the user will have to install this client.
You launch a web server (whatever technology you like). It will expose some web services which will be equally accessible to both desktop and clients OSes. But still you need to write a client application (again 2x).
You run a web server and make all functionality accessible via standard HTTP protocol. This way you won't even need a client - almost every desktop or a mobile OS has at least some web browser installed. JavaScript will provide for dynamic updates of your ticker.
There is a good series of articles about Networking for game programmers by someone who does that stuff for a living.
I'm by no means an expert on network communication, but if you don't mind loosing a few packets (or error checking in software) and you want fast, lean communication you could use UDP. I think most time-sensitive data programs and streaming media use this protocol to avoid delays and keep packet size down.
I realized a Client/ Server app a few years ago with java and ServerSocket (http://java.sun.com/j2se/1.4.2/docs/api/java/net/ServerSocket.html). You also have a SSL version.
So you create a ServerSocket and wait for connexion. When a client is connected, you create a thread that will discuss with this client with a protocol that you made.
http://www.developer.com/java/ent/article.php/1356891/A-PatternFramework-for-ClientServer-Programming-in-Java.htm
If found this little framework :
http://www.bablokb.de/jcs/jcs.html
One of the hardest thing is to create your protocol , a good way to learn how to create one would be to understand how work the FTP (or HTTP ...).
You are correct that the J2EE model breaks down with near-realtime or multi-player demands. You migth want to consider the RedDwarf game server project. It does for games what Servlets do for busienss logic and is open source.
http://www.reddwarfserver.org
I suggest we regard desktop and mobile
systems as equal clients. What options
are then?
RedDwarf has a pluggable trabsport layer and can support any sort of client you wish.
Web servers are great for web type apps. if your game acts like a web page-- is not multi-user, is turn based, and evolves very slowly-- then a web server is a fine chocie.
If it doesn't however, you need something a bit beefier in technology.
Oh, and for what its worth, whetevr you do, if you want to write a server from scratch then DON'T use"ServerSocket." That requries a thread per connection and will never scale. Use NIO or use an NIO framewoprk like Netty.

Resources