All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.udash.rpc.ExposesServerRPC.scala Maven / Gradle / Ivy

There is a newer version: 0.2.0-rc.3
Show newest version
package io.udash.rpc

import io.udash.rpc.internals._
import upickle.Js

import scala.concurrent.{ExecutionContext, Future}

final class ExposesServerRPC[ServerRPCType <: RPC](local: ServerRPCType)(implicit protected val localRpcAsRaw: AsRawRPC[ServerRPCType])
  extends ExposesLocalRPC[ServerRPCType] {

  override protected def localRpc: ServerRPCType = local

  implicit val executionContext: ExecutionContext = internalRPCExecutionContext

  /** Handles RPCCall and returns Future with call result. */
  def handleRpcCall(call: RPCCall): Future[Js.Value] = {
    val receiver = localRpcAsRaw.asRaw(localRpc).resolveGetterChain(call.gettersChain)
    receiver.call(call.invocation.rpcName, call.invocation.argLists)
  }

  /** Handles RPCFire */
  def handleRpcFire(fire: RPCFire): Unit = {
    val receiver = localRpcAsRaw.asRaw(localRpc).resolveGetterChain(fire.gettersChain)
    receiver.fire(fire.invocation.rpcName, fire.invocation.argLists)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy