/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/Boot.scala

https://github.com/markoscalderon/bigbluebutton · Scala · 71 lines · 52 code · 19 blank · 0 comment · 3 complexity · 8f18fc6fecddb09b374a045b8f295ce6 MD5 · raw file

  1. package org.bigbluebutton
  2. import org.bigbluebutton.common2.bus.IncomingJsonMessageBus
  3. import org.bigbluebutton.common2.redis.{ RedisConfig, RedisPublisher }
  4. import org.bigbluebutton.endpoint.redis.FSESLRedisSubscriberActor
  5. import org.bigbluebutton.freeswitch.{ RxJsonMsgHdlrActor, VoiceConferenceService }
  6. import org.bigbluebutton.freeswitch.voice.FreeswitchConferenceEventListener
  7. import org.bigbluebutton.freeswitch.voice.freeswitch.{ ConnectionManager, ESLEventListener, FreeswitchApplication }
  8. import org.freeswitch.esl.client.manager.DefaultManagerConnection
  9. import akka.actor.ActorSystem
  10. import akka.stream.ActorMaterializer
  11. import akka.http.scaladsl.Http
  12. import org.bigbluebutton.service.HealthzService
  13. import scala.concurrent.ExecutionContext
  14. object Boot extends App with SystemConfiguration with WebApi {
  15. override implicit val system = ActorSystem("bigbluebutton-fsesl-system")
  16. override implicit val executor: ExecutionContext = system.dispatcher
  17. override implicit val materializer: ActorMaterializer = ActorMaterializer()
  18. val redisPass = if (redisPassword != "") Some(redisPassword) else None
  19. val redisConfig = RedisConfig(redisHost, redisPort, redisPass, redisExpireKey)
  20. val redisPublisher = new RedisPublisher(
  21. system,
  22. "BbbFsEslAkkaPub",
  23. redisConfig
  24. )
  25. val eslConnection = new DefaultManagerConnection(eslHost, eslPort, eslPassword)
  26. val healthz = HealthzService(system)
  27. val voiceConfService = new VoiceConferenceService(healthz, redisPublisher)
  28. val fsConfEventListener = new FreeswitchConferenceEventListener(voiceConfService)
  29. fsConfEventListener.start()
  30. val eslEventListener = new ESLEventListener(fsConfEventListener)
  31. val connManager = new ConnectionManager(eslConnection, eslEventListener, fsConfEventListener)
  32. connManager.start()
  33. val fsApplication = new FreeswitchApplication(connManager, fsProfile)
  34. fsApplication.start()
  35. val inJsonMsgBus = new IncomingJsonMessageBus
  36. val redisMessageHandlerActor = system.actorOf(RxJsonMsgHdlrActor.props(fsApplication))
  37. inJsonMsgBus.subscribe(redisMessageHandlerActor, toFsAppsJsonChannel)
  38. val channelsToSubscribe = Seq(toVoiceConfRedisChannel)
  39. val redisSubscriberActor = system.actorOf(
  40. FSESLRedisSubscriberActor.props(
  41. system,
  42. inJsonMsgBus,
  43. redisConfig,
  44. channelsToSubscribe,
  45. Nil,
  46. toFsAppsJsonChannel
  47. ),
  48. "redis-subscriber"
  49. )
  50. val apiService = new ApiService(healthz)
  51. val bindingFuture = Http().bindAndHandle(apiService.routes, httpHost, httpPort)
  52. }