com.aispeech.dui

## Class BaseNode

- java.lang.Object
- - com.aispeech.dui.BaseNode

- All Implemented Interfaces:
    BusClient.Handler, java.lang.Runnable
  Direct Known Subclasses:
    Agent

      public abstract class BaseNode
      extends java.lang.Object
      implements java.lang.Runnable, BusClient.Handler

  node life cycle

           onCreate()
              |
           onJoin() -- try join again -----<--
              |                                |
             bus client main loop              |
              |                                |
           onExit() -- exit on exception -->--
              |
           onDestroy()

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected BusClient` | `bc`
    `static java.lang.String` | `DEFAULT_BUS_SERVER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BaseNode()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dump(java.io.PrintWriter pw)`
    `void` | `dump(java.io.PrintWriter pw, java.lang.String args)`
    `java.lang.String` | `getAddress()`
    `int` | `getBufferSize()` invoked when this node need larger buffer for communication
    `BusClient` | `getBusClient()`
    `abstract java.lang.String` | `getName()`
    `boolean` | `isRunning()`
    `void` | `onCreate()` invoked when this node is created
    `void` | `onDestroy()` invoked when this node is being destroyed
    `void` | `onExit()` invoked when this node exit from bus
    `void` | `onJoin()` invoked when this node join bus
    `void` | `onMessage(java.lang.String topic, byte[]... parts)` invoked when topic received.
    `void` | `onRetry(int retryCount)`
    `void` | `publishSticky(java.lang.String topic, java.lang.String... parts)` The topic will always be delivered to subscribers 1.
    `void` | `removeSticky(java.lang.String topic)` The topic will be not sticky anymore Remove the recent sticky topic kept in memory
    `void` | `run()`
    `boolean` | `start()`
    `boolean` | `stop()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.aispeech.dui.BusClient.Handler

      `onCall`

- - ### Field Detail

    - #### bc

          protected BusClient bc

    - #### DEFAULT_BUS_SERVER

          public static java.lang.String DEFAULT_BUS_SERVER

  - ### Constructor Detail

    - #### BaseNode

          public BaseNode()

  - ### Method Detail

    - #### getName

          public abstract java.lang.String getName()

    - #### onCreate

          public void onCreate()

      invoked when this node is created

    - #### onJoin

          public void onJoin()

      invoked when this node join bus

    - #### onExit

          public void onExit()

      invoked when this node exit from bus

    - #### onRetry

          public void onRetry(int retryCount)

    - #### onDestroy

          public void onDestroy()

      invoked when this node is being destroyed

    - #### getAddress

          public java.lang.String getAddress()

    - #### onMessage

          public void onMessage(java.lang.String topic,
                                byte[]... parts)
                         throws java.lang.Exception

      invoked when topic received.

      only handle bus.event in BaseNode

      Specified by:
        `onMessage` in interface `BusClient.Handler`
      Parameters:
        `topic` -
        `parts` -
      Throws:
        `java.lang.Exception`

    - #### dump

          public void dump(java.io.PrintWriter pw,
                           java.lang.String args)

    - #### dump

          public void dump(java.io.PrintWriter pw)

    - #### getBufferSize

          public int getBufferSize()

      invoked when this node need larger buffer for communication
      Returns:
        the size of socket receiver & sender buffer, Bytes

    - #### getBusClient

          public final BusClient getBusClient()

    - #### run

          public void run()

      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### isRunning

          public final boolean isRunning()

    - #### start

          public final boolean start()

    - #### stop

          public final boolean stop()

    - #### publishSticky

          public void publishSticky(java.lang.String topic,
                                    java.lang.String... parts)

      The topic will always be delivered to subscribers 1. no matter aios has ready or not. 2. no matter subscriber invokes bc.subscribe earlier or later. The most recent sticky topic is kept in memory for future access by subscribers
      Parameters:
        `topic` - sticky topic to publish
        `parts` - content

    - #### removeSticky

          public void removeSticky(java.lang.String topic)

      The topic will be not sticky anymore Remove the recent sticky topic kept in memory
      Parameters:
        `topic` - sticky topic to remove