Packages

p

io.youi

communication

package communication

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait Communication extends ErrorSupport

    Communication provides convenience functionality to communicate between a client and server (two-way) via WebSockets.

    Communication provides convenience functionality to communicate between a client and server (two-way) via WebSockets. The supported mechanisms are methods and shared variables.

    Method Example:

    @server def time: Future[Long]
    

    Notice the

    @server
    
    annotation. This represents that this method will be defined in the server implementation allowing the client to call the method and it is invoked on the server and the result is received on the client. To create a method in the client that is called from the server simply use the
    @client
    
    annotation instead. The return type of the method must be of
    Future
    
    or it will be ignored.

    Shared Var Example:

    val name: reactify.Var[String] = shared[String]("Default")
    

    This represents a variable that is shared between the client and server. Either can change the value and it will be reflected in the other asynchronously. We use Reactify's

    Var
    
    because it allows functional reactive observing of changes.

    Note that three traits must be defined for a

    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Var
    observing of changes. Note that three traits must be defined for a
    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Future
    Shared Var Example:
    val name: reactify.Var[String] = shared[String]("Default")
    
    This represents a variable that is shared between the client and server. Either can change the value and it will be reflected in the other asynchronously. We use Reactify's
    Var
    
    because it allows functional reactive observing of changes. Note that three traits must be defined for a
    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Var
    observing of changes. Note that three traits must be defined for a
    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. @server
    implementation allowing the client to call the method and it is invoked on the server and the result is received on the client. To create a method in the client that is called from the server simply use the
    @client
    
    annotation instead. The return type of the method must be of
    Future
    
    or it will be ignored. Shared Var Example:
    val name: reactify.Var[String] = shared[String]("Default")
    
    This represents a variable that is shared between the client and server. Either can change the value and it will be reflected in the other asynchronously. We use Reactify's
    Var
    
    because it allows functional reactive observing of changes. Note that three traits must be defined for a
    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Var
    observing of changes. Note that three traits must be defined for a
    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Future
    Shared Var Example:
    val name: reactify.Var[String] = shared[String]("Default")
    
    This represents a variable that is shared between the client and server. Either can change the value and it will be reflected in the other asynchronously. We use Reactify's
    Var
    
    because it allows functional reactive observing of changes. Note that three traits must be defined for a
    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Var
    observing of changes. Note that three traits must be defined for a
    Communication
    
    : 1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time. Communication
    1. Shared Interface (defined as the definition of each method and shared variable):
        trait ExampleCommunication extends Communication {
          @server def time: Future[Long]
          @client def url: Future[String]
          val name: Var[String] = shared[String]("Default")
        }
      
    2. Client Interface (defined in Scala.js code):
      
        trait ClientExampleCommunication extends ExampleCommunication {
          override def url: Future[String] = Future.successful(document.url.href)
        }
    
    3. Server Interface (defined in JVM code):
        trait ServerExampleCommunication extends ExampleCommunication {
          override def time: Future[Long] = Future.successful(System.currentTimeMillis())
        }
    
    Notice that only the methods that need to be implemented on the client or server are defined. The rest are generated at compile-time.

    See also

    io.youi.app.YouIApplication for usage examples

  2. class CommunicationException extends RuntimeException
  3. class CommunicationInternal extends AnyRef
  4. case class CommunicationMessage (messageType: Int, endPoint: String, invocationId: Int, content: List[String], error: Option[String]) extends Product with Serializable
  5. class client extends Annotation with StaticAnnotation
  6. class server extends Annotation with StaticAnnotation

Value Members

  1. object Communication
  2. object CommunicationMessage extends Serializable
  3. object Macros
    Annotations
    @compileTimeOnly( "Enable Macros for expansion" )

Ungrouped