jrudolph / pekko-http-scala-js-websocket-chat Goto Github PK
View Code? Open in Web Editor NEWAn example app that integrates pekko-http and scala-js to implement a websocket chat
License: MIT License
An example app that integrates pekko-http and scala-js to implement a websocket chat
License: MIT License
[error] C:\...\akka-http-scala-js-websocket-chat\project\project\ScalariformSupport.scala:1: expected class or object definition
[error] ../ScalariformSupport.scala
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
Issue already out there: http://stackoverflow.com/questions/5917249/git-symlinks-in-windows
See
// TODO - Definition should move to a separate shared sub-project between client and server.
case class ChatMessage(sender: String, message: String)
in FrontEnd.scala, and
case class ChatMessage(sender: String, message: String)
in Chat.scala.
Ideally, there'd just be one ChatMessage case class (and any (de-)serialization logic for it) defined.
currently only localhost on own machine is possible.
Thanks for this example!
I'm trying to retrofit a wandoulabs-powered WebSockets server, moving to akka-io. I asked about this on the akka-user mailing list recently.
In my app, my "chatActor" looks something like this (not too dissimilar to yours)
sealed trait Incoming //... impls
sealed trait Outgoing //... impls
class SimpleActor(upstream: ActorRef) extends Actor {
def receive = {
case in: Incoming =>
// work, including some upstream ! outgoing
case Ack =>
// ack for the last message upstream
case other =>
// work, including some upstream ! outgoing
}
}
The amount of data (and the pace of transmission) is really high, so I have to use backpressure or it blows up the heap and I/O stacks. I've been doing that with akka-io's Ack
mechanism to become
"waiting for Ack and stashing".
However, it seems that turning an actor into a Sink
the way you're doing it throws away all the backpressure information, from the Akka docs:
there is no back-pressure signal from the destination actor, i.e. if the actor is not consuming the messages fast enough the mailbox of the actor will grow
That's kinda concerning, because I don't want to take messages off the queue unless I can process them. But, anyway...
On the producer side of things, I actually can't figure out how the Source
construction is even working in your example to be honest, because there is no explicit actor target for the chatActor
on construction, so I need to study it some more. In any case, can there be backpressure here? Because if there is no backpressure here then I basically can't use akka-io.
What I really need is the ability to create a Flow[In, Out]
from an actor that already receives In
and sends Out
messages to an upstream: ActorRef
, handling the Ack
messaging (which I'm prepared to refactor to fit in to the akka-stream way of doing it).
Any tips on the easiest place of where to start? One thing I'd like to do is connect this to a DB so any user will have full history. Any pointers in general? (this will be my first ever Scala project)
Forked the repository and tried to bootstrap the project trough sbt with as described in the readme.md
getting this error
[info] Resolving com.typesafe.sbt#sbt-scalariform;1.2.1 ...
[warn] module not found: com.typesafe.sbt#sbt-scalariform;1.2.1
[warn] ==== local: tried
[warn] /Users/lucian/.ivy2/local/com.typesafe.sbt/sbt-scalariform/scala_2.10/sbt_0.13/1.2.1/ivys/ivy.xml
[warn] ==== jcenter: tried
[warn] https://jcenter.bintray.com/com/typesafe/sbt/sbt-scalariform_2.10_0.13/1.2.1/sbt-scalariform-1.2.1.pom
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbt/sbt-scalariform/1.2.1/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/typesafe/sbt/sbt-scalariform_2.10_0.13/1.2.1/sbt-scalariform-1.2.1.pom
[info] Resolving org.scala-js#sbt-scalajs;0.6.5 ...
[warn] module not found: org.scala-js#sbt-scalajs;0.6.5
[warn] ==== local: tried
[warn] /Users/lucian/.ivy2/local/org.scala-js/sbt-scalajs/scala_2.10/sbt_0.13/0.6.5/ivys/ivy.xml
[warn] ==== jcenter: tried
[warn] https://jcenter.bintray.com/org/scala-js/sbt-scalajs_2.10_0.13/0.6.5/sbt-scalajs-0.6.5.pom
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/org.scala-js/sbt-scalajs/0.6.5/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/scala-js/sbt-scalajs_2.10_0.13/0.6.5/sbt-scalajs-0.6.5.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbt#sbt-scalariform;1.2.1: not found
[warn] :: org.scala-js#sbt-scalajs;0.6.5: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.typesafe.sbt:sbt-scalariform:1.2.1 (scalaVersion=2.10, sbtVersion=0.13)
[warn] org.scala-js:sbt-scalajs:0.6.5 (scalaVersion=2.10, sbtVersion=0.13)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.typesafe.sbt:sbt-scalariform:1.2.1 (scalaVersion=2.10, sbtVersion=0.13) (/Users/lucian/Workspace/akka-http-scala-js-websocket-chat/project/plugins.sbt#L1-2)
[warn] +- default:akka-http-scala-js-websocket-chat-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)
[warn] org.scala-js:sbt-scalajs:0.6.5 (scalaVersion=2.10, sbtVersion=0.13) (/Users/lucian/Workspace/akka-http-scala-js-websocket-chat/project/plugins.sbt#L5-6)
[warn] +- default:akka-http-scala-js-websocket-chat-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: com.typesafe.sbt#sbt-scalariform;1.2.1: not found
unresolved dependency: org.scala-js#sbt-scalajs;0.6.5: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:294)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:132)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
at sbt.IvySbt.withIvy(Ivy.scala:127)
at sbt.IvySbt.withIvy(Ivy.scala:124)
at sbt.IvySbt$Module.withModule(Ivy.scala:155)
at sbt.IvyActions$.updateEither(IvyActions.scala:168)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1392)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1388)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1422)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1420)
at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1425)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1419)
at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
at sbt.Classpaths$.cachedUpdate(Defaults.scala:1442)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1371)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1325)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.sbt#sbt-scalariform;1.2.1: not found
[error] unresolved dependency: org.scala-js#sbt-scalajs;0.6.5: not found
Any thoughts ?
This doesn't work on a remote server... I get a 400 error on the websocket. It has to do something with CORS but the documentation is super clear not.
Can you add the CORS module and define it so it is 100% usable on a wss://remote connection not just a local one? Every single example out there only talks of a local connection for that matter.
js source map file and jsdeps.js are missing in backend package.
brower(firefox or chrome) can't find "frontend-fastopt.js.map" and "frontend-jsdeps.js".
i can find the files in the frontend project directory, but they are missing in the backend project.
how can i add these files to backend project?
and, if i want use "frontend-jsdeps.min.js" in the backend project, what should i do?
thx.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.