Hi, injecting frames manually is not supported. Not supported means that we don't offer an API that would allow users to do that.
That said, there's an internal API that allows to specify a frame handler directly: * You can case the `UpgradeToWebsocket` header to `UpgradeToWebsocketLowLevel`, this allows you to specify a frame handler flow: https://github.com/akka/akka-http/blob/5932237a86a432d623fafb1e84eeeff56d7485fe/akka-http-core/src/main/scala/akka/http/impl/engine/ws/UpgradeToWebSocketLowLevel.scala#L16-L16 * The difference between the frame handler and full stack can be basically seen here: https://github.com/akka/akka-http/blob/74148fefccd7d51fe2b18356885a4267b279a73c/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala#L622-L622 * Websocket.stack is implemented here: https://github.com/akka/akka-http/blob/5932237a86a432d623fafb1e84eeeff56d7485fe/akka-http-core/src/main/scala/akka/http/impl/engine/ws/WebSocket.scala#L34 As you can see `Websocket.stack` is just a stack of stages. If you wanted inject and intercept control frames you could basically copy the implementation of `stack` and put another custom stage between `masking` and `frameHandling`. Obviously, you need to know what you are doing not to disrupt the usual way things work. Just injecting `Ping` frames and listening to `Pong` frames should be quite simple, though. All of these classes are `private[akka]` or `private[http]` so you need to implement anything inside of an `akka.http` package in your project. Good luck and have fun ;) Johannes On Thursday, December 22, 2016 at 7:15:03 PM UTC+1, Muthu Jayakumar wrote: > > Hello there, > > I am new to akk-http on writing a web-socket server side code (have > written one using Spray-IO though). My question is on how I would be able > to use the server-side apis to send other kinds of control-frames? By the > spec @ https://tools.ietf.org/html/rfc6455#page-36 > Close > Ping > Pong > Data -- Text -- Binary > The apis have the TextFrame and BinaryFrame part of the Frame covered. I > guess, the PingFrame and PongFrame would be useful to have the server-side > api to help in the "keep-alive" attribute to the connection(as quoted from > the spec: "NOTE: A Ping frame may serve either as a keepalive or as a > means to verify that the remote endpoint is still responsive."). The same > question on CloseFrame may be useful I guess? > > Please advice, > Muthu > > On a side note... > On top of the akka documentation @ > http://doc.akka.io/docs/akka-http/current/scala/http/websocket-support.html, > I found the following article useful in getting Web-Socket to hook-up thru > actor(s) - > https://markatta.com/codemonkey/blog/2016/04/18/chat-with-akka-http-websockets/ > . > To me the gap is on understanding akka-streams better. Not sure if may be > useful for the documentation to give some hints on how 'server-push' can be > achieved using some code snippet similar to this blog? > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
