System Designer

System Designer

  • Languages icon繁體中文
    • English
    • Ελληνικά
    • Português (Brasil)
    • Svenska
    • Help Translate
  • SUPPORT
  • GITHUB

›Tutorials

Introduction

  • What is System Designer?
  • What is Design First?
  • Quick Start
  • Quick Start in videos

Guides

  • Installation
  • Create a System
  • 創建一個模式
  • Edit a model
  • Create a Behavior
  • Create a Type
  • Create a Component
  • Run your System
  • Export a System
  • Import a System
  • Generate a diagram
  • Sync your systems with GitHub
  • Design a remote client system
  • Design a remote server system
  • Manage Extensions
  • Extend System Designer
  • Shortcuts

Tutorials

  • List of Examples
  • Bundle your CSS
  • Bundle your JavaScript
  • Bundle your HTML
  • Test a server-side application
  • Create a NPM module
  • Create a website
  • Listen to a model event
  • Listen to a data store event
  • Send messages
  • Send messages to other systems
  • Create an extension
  • Generate a model from a JSON file
  • Create a Graph system

Articles

  • 關於這個開源方案

About

  • Who is behind System Designer?
  • Privacy Policy
  • License
Translate

Send messages

In this tutorial we will show how to react to messages send by the system.

At runtime a channel component is defined to send messages.

Define the message

After creating a system:

  • click on the import button on the left toolbar,
  • a dialog is shown,
  • click on from the library radio button,
  • select Send messages through a channel from the proposed systems,
  • click on the Compose button,

Image Alt

This system has now been composed in your system.

  • on Schemas tab, click on _Channel schema (on the right panel under Schemas),

Image Alt

  • click on _Channel schema to edit it,
  • add somethingHappened event:
{
  "_id": "104ad1f48518376",
  "_name": "_Channel",
  "_inherit": [
    "_Component"
  ],
  "send": "event",
  "somethingHappened": "event"
}
  • on Models tab, click on _Channel model (on the right panel under Models),

Image Alt

  • click on _Channel model,
  • edit with this code:
{
  "_id": "135c71078810af2",
  "_name": "_Channel",
  "send": {
    "params": [
      {
        "name": "message",
        "type": "message"
      }
    ]
  },
  "somethingHappened": {
    "description": "",
    "params": [
      {
        "description": "",
        "name": "param",
        "type": "string",
        "mandatory": false,
        "default": ""
      }
    ]
  }
}

Define the listener

Now we will create the listener to that message:

  • on Behaviors tab, click on _Channel model (on the right panel under Models),
  • then click on channel component (on the right panel under Components),
  • click on the '+' button on the left toolbar to add a behavior,
  • select somethingHappened from the list,
  • click on the Create button

Image Alt

  • click on the somethingHappened behavior,
  • add this code:
function somethingHappened(param) { 
  // get logger component
  let logger = this.require('logger');

  logger.info('the message "' + param + '" has been send.');
}

Image Alt

Send the message

  • on Behavior tab, select your system (on the right panel under System),
  • click on start behavior,
  • add this code:
function start() { 
  this.require('channel').somethingHappened('my message');  
}

Image Alt

  • run your system

Image Alt

  • you will see a message on the bottom right of System Designer and a new log on the Logs tab.
← Listen to a data store eventSend messages to other systems →
  • Define the message
  • Define the listener
  • Send the message
System Designer is distributed under Apache License 2.0 - Copyright © 2024 Erwan Carriou