So I made this website to use websockets. All was good on my localhost and then I decided to deploy on Heroku. This broke the website because Heroku does not support websockets!
I wonder if anyone has written a simple adapter that allows me to use comet on the front-end and trick my Scala Play 2.1 server into thinking it's using websockets on the back end. Then I could use another adapter on the front-end to trick it into thinking it's using websockets as well and I wouldn't have to change too much code.
I found this using google: http://www.playframework.com/documentation/2.0/ScalaComet
Is that what you need?
Related
Is there any limitation in using a library like stanza.io for communication with an XMPP server like MongooseIM in Nativescript? What other alternatives are there?
If stanza.io supports NativeScript then there should not be any limitations.
On their GitHub main pager they say it's a Modern XMPP in the browser, with a JSON API. So it's mainly for browser env and I'm not sure about NativeScript.
As an alternative way - there is a xmpp.js lib which supports NativeScript. Their doc is a little bit shitty, but using src code there is a way to integrate successfully it.
There is a guide on how to use it for ReactNative, but you can some part from it for NativeScript, especially these part that are connected to the lib itself.
https://medium.com/#connectycube/xmpp-real-time-chat-in-react-native-8d6d5d23dd47
Also you can use some ready XMPP high level platforms for Chat, e.g. https://connectycube.com/2018/12/11/connectycube-textchat-code-sample-for-nativescript/
In this case you do not need to carte about XMPP server installation and monitoring
You will have to find a third party server or host your own one that implements XMPP protocols and connect to same using Websockets or XMPP plugin from your {N} application.
FYI, This XMPP plugin implements the same pod library explained in the MongooseIM docs, but the JavaScript apis are not fully implemented so you might have to access the native apis directly as needed.
You may also refer nativescript-xmpp-client, another exampel for XMPP implementation.
I am somewhat new to the domain of web development. I am investigating Play2 and am trying to understand, do you need some kind of JS frontend framework to go with Play2 and Scala?
I notice that Play2 has a template engine, but it seems that it generates the HTML on the server and sends it to the browser. Does this mean that the need for a JS frontend like Angular2 is made irrelevant? Or is there still a reason to use Angular2 in a Play2 application? What instances would it make sense and why?
I have some experience of using Play 2 with AngularJS (currently rewriting frontend to Angular2).
I use Play 2 (scala) only for RESTful JSON backend, which is just great for this purpose and I use Angular for single page application frontend. I find this combination brilliant.
My project is hosted on GitHub, you can check it out here
There are three directories in the root:
restful with all backend stuff, written in scala, using Slick for DB,
taking advantage of Play evolutions and all other stuff.
angularjs-client-deprecated with AngularJS code. I used angular-resource for making calls to backend.
client with Angular2 code. There is nothing there so far except for my experiments, however I've written a simple service for authentication with security token.
To summarise, I've been developing my project for almost 2 months so far, mainly to learn both Scala and AngularJS (now Angular2).
If you're planning to use JS framework for frontend, I would recommend you to use Play2 only for RESTFul Json backend. I don't see a reason to use Play2 html template engine in this case.
Play is more about Server Side templating, which isn't all that useful if you're using Angular. It can be done, but it comes with some overhead. I've worked with Scalatra in the past and it worked really well for me.
http://scalatra.org/
Other options include Spray, which is very similar from the outside, but uses Akka internally and uses non-blocking I/O, similar to Play!
http://spray.io/
With angular it is better to go with simple rest/http api like Akka-IO or spray for data and other stuff. Play will be less relevant with Angular.
As others have pointed out Play2 isn't really the best option for building responsive websites. I have a seed project which can help you get started with Akka Http and Angular 5...already configured to deploy to Heroku in a single web dyno.
https://github.com/jdschmitt/akka-angular-heroku
Check it out. I hope it helps anyone landing here looking for a way to manage back-end and front-end in a single repo for simple projects.
Is there any good library which supports WebSockets and is compatible with GWT? Ideally, the library would support WebSockets as well as a fallback for browsers which don't support WebSocket, e.g. a comet-like approach or polling.
I'm currently using GWT-Comet to push data from my server to my GWT web application. However, this library is a bit broken in some aspects and it seems it's not maintained actively anymore. Thus, I'm searching for an alternative.
I found Atmosphere, which suits the needs stated in the question pretty good. It supports GWT, and also Websockets. Also, it supports many different application Servers, like Tomcat and Jetty.
Is it possible to host a GWT-compiled web application in NodeJS?
I like NodeJS however there are lots of work already made with GWT for my projects.
Cheers.
On the client side, as #riley-lark said.
You can also use GWT code on the server-side on NodeJS; see https://github.com/cretz/gwt-node and http://code.google.com/p/gwt-exporter/
Yes. GWT is a client-side technology and does not need to interact with your server at all. It is possible to send arbitrary requests to any server and process the feedback.
You won't be able to use GWT-RPC or RequestFactory.
I am developing one application with GWT as client and my server side code written in Java servelt and I am fetching some data from another server. that another server code is in Scala. so the question is how can i push data from another server to my main server and display that data to client using comet ( gwt-comet.jar)
Please help me.
Thanks
Comet is something that your web server must support, via continuations or some other implementation (see this as an example). Usually web frameworks (like Lift) have some wrapper around this mechanism to facilitate using it.
I'm no expert on GWT, but for what you say it seems it has a Comet library. Using it should be as simple as to implement classes following this library specifications and using a server that supports Comet.