aboutsummaryrefslogtreecommitdiff
path: root/mavigator-server/src/main/scala/mavigator/Router.scala
blob: bd54422ccf1f938346e5121503554e50f8655d35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package mavigator

import akka.actor._
import akka.stream._
import akka.stream.scaladsl._
import akka.http.scaladsl._
import akka.http.scaladsl.model._
import akka.http.scaladsl.server._


class Router(system: ActorSystem) {

  import Directives._

  val route: Route = (
    path("info") {
      get {
        val f: play.twirl.api.Html = mavigator.views.html.index()
        complete(f.body)
      }
    } ~
    path("dashboard" / IntNumber) { id =>
      get {
        //get dashboard for remote sys id
        ???
      }
    } ~
    path("mavlink") {
      get {
        /*extractUpgradeToWebsocket{ upgrade =>
          //upgrade.handleMessagesWith(inSink: Sink[Message, _$3], outSource: Source[Message, _$4])
          ???
         }*/
        handleWebsocketMessages((new MavlinkWebsocket(system)).wsflow)
      }
    } ~
    pathPrefix("assets") {
      get {
        encodeResponse {
          getFromResourceDirectory("assets")
        }
      }
    } ~
    pathEndOrSingleSlash {
      get {
        complete("hello world")
      }
    }
  )

}

import akka.http.scaladsl.model.ws._
import akka.stream.scaladsl._

object SocketService {

  /*
  val out: Source[OutgoingMessage, ActorRef] = Source.actorRef[OutgoingMessage](0, OverflowStrategy.fail)
  val in = Sink.actorRef(ref: ActorRef, onCompleteMessage: Any)
   */


  /*
  Flow[Message, Message, _] { implicit builder =>

    val in: Flow[Message, IncomingMessage, _] = Flow[Message].map {
      case TextMessage.Strict(txt) => IncomingMessage(s"frpm websocket $txt")
      case _ => ???
    }

    val out: Flow[OutgoingMessage, Message, _] = Flow[OutgoingMessage].map {
      case OutgoingMessage(txt) => TextMessage(s"to websocket $text")
    }

    val chatActorSink = Sink.actorRef[ChatEvent](chatRoomActor, UserLeft(user))

  }
 */
}

/*
object EchoService {

  val flow: Flow[Message, Message, _] = Flow[Message].map {
    case TextMessage.Strict(txt) => TextMessage("ECHO: " + txt)
    case _ => TextMessage("Message type unsupported")
  }

}
 */