scala - Akka-Http WebSocket: Akka stream use WebSocket as a sink -


using akka-http , akka-streams version 2.4 how can construct stream has sink websocket.

for example have source generates random numbers, these numbers filtered, lets keep numbers, flow websocket sink.

thanks

this code put akka http route output continuous stream of random numbers without overwhelming websocket

path("randomnums") {   val src =     source.fromiterator(() => iterator.continually(threadlocalrandom.current.nextint()))           .filter(i => > 0 && % 2 == 0).map(i => textmessage(i.tostring))      extractupgradetowebsocket { upgrade =>       complete(upgrade.handlemessageswithsinksource(sink.ignore, src))     } } 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -