SlideShare a Scribd company logo
Copyright © 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 9
Complex QEWD messages and
responses
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright © 2016 M/Gateway Developments Ltd
Sending complex messages
• So far we've just sent the simplest
message possible:
– Only has a type property, and no additional
content or payload
• Messages can be as big and as complex
as you like
– Just JavaScript objects
Copyright © 2016 M/Gateway Developments Ltd
Sending complex messages
• Define the content or payload in the
message object's params property
var messageObj = {
type: 'login',
params: {
username: $('#username').val(),
password: $('#password').val()
}
};
EWD.send(messageObj, callbackFn);
Copyright © 2016 M/Gateway Developments Ltd
Handling Complex Messages
• In back-end handler, params available via
messageObj.params:
login: function(messageObj, session, send, finished) {
var username = messageObj.params.username;
if (username === '') {
finished({error: 'You must enter a username');
return;
}
var password = messageObj.params.password;
if (password === '') {
finished({error: 'You must enter a password');
return;
}
// …etc
}
Copyright © 2016 M/Gateway Developments Ltd
Sending complex messages
• Params can be as complex an object as
you wish
var messageObj = {
type: 'complex',
params: {
foo: 'bar',
subObj: {
hello: 'world',
name: 'rob'
},
arr: ['a', 'b', 'c']
}
};
EWD.send(messageObj, callbackFn);
Copyright © 2016 M/Gateway Developments Ltd
Sending complex messages
• Params can be as complex an object as
you wish
var messageObj = {
type: 'complex',
params: {
foo: 'bar',
subObj: {
hello: 'world',
name: 'rob'
},
arr: ['a', 'b', 'c']
}
};
EWD.send(messageObj, callbackFn);
At back-end:
var name = messageObj.params.subObj.name;
Copyright © 2016 M/Gateway Developments Ltd
Sending complex messages
• Params can be as complex an object as
you wish
var messageObj = {
type: 'complex',
params: {
foo: 'bar',
subObj: {
hello: 'world',
name: 'rob'
},
arr: ['a', 'b', 'c']
}
};
EWD.send(messageObj, callbackFn);
At back-end:
var b = messageObj.params.arr[1];
Copyright © 2016 M/Gateway Developments Ltd
Returning Complex Responses
• The response object returned by the back-
end handler's send() or finished() functions
can be as complex as you want
• Be careful with the response size:
– Can significantly slow down ewd-qoper8
– The larger the response, the longer it takes
for Express to return it to the browser or client
Copyright © 2016 M/Gateway Developments Ltd
Returning Complex Responses
finished({
foo: 'bar',
myObj: {
hello: 'world',
name: 'Rob'
}
myArr: ['a','b','c']
});
Copyright © 2016 M/Gateway Developments Ltd
Returning Complex Responses
finished({
foo: 'bar',
myObj: {
hello: 'world',
name: 'Rob'
}
myArr: ['a','b','c']
});
Accessed in browser-side
response handler as:
responseObj.message.myObj.name
In both EWD.send()'s callback
and Pub/Sub handler

More Related Content

PDF
EWD 3 Training Course Part 20: The DocumentNode Object
PDF
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
PDF
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
PDF
EWD 3 Training Course Part 4: Installing & Configuring QEWD
PDF
Umleitung: a tiny mochiweb/CouchDB app
PDF
Play Framework: async I/O with Java and Scala
PDF
Treinamento frontend
ODP
An Introduction to Windows PowerShell
EWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 4: Installing & Configuring QEWD
Umleitung: a tiny mochiweb/CouchDB app
Play Framework: async I/O with Java and Scala
Treinamento frontend
An Introduction to Windows PowerShell

What's hot (20)

PPT
Introduction to PowerShell
PDF
Cape Cod Web Technology Meetup - 2
PDF
Overview Of Lift Framework
PDF
Overview of The Scala Based Lift Web Framework
PPTX
Play + scala + reactive mongo
PDF
Communication in Node.js
PDF
Rails Caching Secrets from the Edge
PDF
Asynchronous web apps with the Play Framework 2.0
PDF
Distributed Ruby and Rails
PDF
Securing Prometheus exporters using HashiCorp Vault
KEY
Dancing with websocket
KEY
Building a real life application in node js
PPTX
Webinar: Building Your First App in Node.js
PDF
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
PPT
Developing node-mdb: a Node.js - based clone of SimpleDB
ODP
Asynchronous I/O in NodeJS - new standard or challenges?
KEY
What is the ServiceStack?
PDF
Serverless Java on Kubernetes
PDF
Introduction to Node.js
PPTX
Mojo – Simple REST Server
Introduction to PowerShell
Cape Cod Web Technology Meetup - 2
Overview Of Lift Framework
Overview of The Scala Based Lift Web Framework
Play + scala + reactive mongo
Communication in Node.js
Rails Caching Secrets from the Edge
Asynchronous web apps with the Play Framework 2.0
Distributed Ruby and Rails
Securing Prometheus exporters using HashiCorp Vault
Dancing with websocket
Building a real life application in node js
Webinar: Building Your First App in Node.js
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Developing node-mdb: a Node.js - based clone of SimpleDB
Asynchronous I/O in NodeJS - new standard or challenges?
What is the ServiceStack?
Serverless Java on Kubernetes
Introduction to Node.js
Mojo – Simple REST Server
Ad

Viewers also liked (18)

PDF
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
PDF
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle
PDF
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
PDF
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
PDF
EWD 3 Training Course Part 11: Handling Errors in QEWD
PDF
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
PDF
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
PDF
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
PDF
EWD 3 Training Course Part 12: QEWD Session Timeout Control
PDF
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
PDF
EWD 3 Training Course Part 3: Summary of EWD 3 Modules
PDF
EWD 3 Training Course Part 19: The cache.node APIs
PDF
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD
PDF
EWD 3 Training Course Part 16: QEWD Services
PPT
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
PDF
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
PDF
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
PDF
EWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
EWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 12: QEWD Session Timeout Control
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
EWD 3 Training Course Part 3: Summary of EWD 3 Modules
EWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD
EWD 3 Training Course Part 16: QEWD Services
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 21: Persistent JavaScript Objects
Ad

Similar to EWD 3 Training Course Part 9: Complex QEWD Messages and Responses (20)

PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
PPT
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
PDF
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
PDF
Serverless security: attack & defense
PPT
Implementing WebServices with Camel and CXF in ServiceMix
PPTX
Beth Barnham Schema Auditing BrightonSEO Slides.pptx
PPTX
Beth Barnham Schema Auditing BrightonSEO Slides.pptx
PDF
Zend Framework Components for non-framework Development
PDF
Serverless Ballerina
KEY
Sinatra for REST services
KEY
Doing Things the WordPress Way
PDF
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
PDF
Nodejs meetup-12-2-2015
PDF
SproutCore and the Future of Web Apps
PDF
How happy they became with H2O/mruby and the future of HTTP
KEY
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
PPT
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
ODP
Ractive js
PDF
PDF
WSO2 Micro Services Server - Basic Workshop Part 1
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
Serverless security: attack & defense
Implementing WebServices with Camel and CXF in ServiceMix
Beth Barnham Schema Auditing BrightonSEO Slides.pptx
Beth Barnham Schema Auditing BrightonSEO Slides.pptx
Zend Framework Components for non-framework Development
Serverless Ballerina
Sinatra for REST services
Doing Things the WordPress Way
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Nodejs meetup-12-2-2015
SproutCore and the Future of Web Apps
How happy they became with H2O/mruby and the future of HTTP
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
Ractive js
WSO2 Micro Services Server - Basic Workshop Part 1

More from Rob Tweed (20)

PDF
QEWD Update
PPT
Data Persistence as a Language Feature
PPT
LNUG: Having Your Node.js Cake and Eating It Too
PPT
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
PPT
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
PPT
QEWD.js, JSON Web Tokens & MicroServices
PPT
QEWD.js: Have your Node.js Cake and Eat It Too
PDF
qewd-ripple: The Ripple OSI Middle Tier
PPT
EWD 3 Training Course Part 42: The QEWD Docker Appliance
PDF
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
PDF
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
PDF
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
PDF
EWD 3 Training Course Part 35: QEWD Session Locking
PDF
EWD 3 Training Course Part 34: QEWD Resilient Mode
PDF
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
PDF
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
PDF
EWD 3 Training Course Part 30: Modularising QEWD Applications
PDF
EWD 3 Training Course Part 29: Running QEWD as a Service
PDF
EWD 3 Training Course Part 27: The QEWD Session
QEWD Update
Data Persistence as a Language Feature
LNUG: Having Your Node.js Cake and Eating It Too
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
QEWD.js, JSON Web Tokens & MicroServices
QEWD.js: Have your Node.js Cake and Eat It Too
qewd-ripple: The Ripple OSI Middle Tier
EWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 29: Running QEWD as a Service
EWD 3 Training Course Part 27: The QEWD Session

Recently uploaded (20)

PDF
Digital Strategies for Manufacturing Companies
PPT
Introduction Database Management System for Course Database
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
System and Network Administraation Chapter 3
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Odoo Companies in India – Driving Business Transformation.pdf
Digital Strategies for Manufacturing Companies
Introduction Database Management System for Course Database
ManageIQ - Sprint 268 Review - Slide Deck
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
CHAPTER 2 - PM Management and IT Context
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Softaken Excel to vCard Converter Software.pdf
Understanding Forklifts - TECH EHS Solution
How to Choose the Right IT Partner for Your Business in Malaysia
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
ISO 45001 Occupational Health and Safety Management System
PTS Company Brochure 2025 (1).pdf.......
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
System and Network Administraation Chapter 3
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Odoo Companies in India – Driving Business Transformation.pdf

EWD 3 Training Course Part 9: Complex QEWD Messages and Responses

  • 1. Copyright © 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 9 Complex QEWD messages and responses Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright © 2016 M/Gateway Developments Ltd Sending complex messages • So far we've just sent the simplest message possible: – Only has a type property, and no additional content or payload • Messages can be as big and as complex as you like – Just JavaScript objects
  • 3. Copyright © 2016 M/Gateway Developments Ltd Sending complex messages • Define the content or payload in the message object's params property var messageObj = { type: 'login', params: { username: $('#username').val(), password: $('#password').val() } }; EWD.send(messageObj, callbackFn);
  • 4. Copyright © 2016 M/Gateway Developments Ltd Handling Complex Messages • In back-end handler, params available via messageObj.params: login: function(messageObj, session, send, finished) { var username = messageObj.params.username; if (username === '') { finished({error: 'You must enter a username'); return; } var password = messageObj.params.password; if (password === '') { finished({error: 'You must enter a password'); return; } // …etc }
  • 5. Copyright © 2016 M/Gateway Developments Ltd Sending complex messages • Params can be as complex an object as you wish var messageObj = { type: 'complex', params: { foo: 'bar', subObj: { hello: 'world', name: 'rob' }, arr: ['a', 'b', 'c'] } }; EWD.send(messageObj, callbackFn);
  • 6. Copyright © 2016 M/Gateway Developments Ltd Sending complex messages • Params can be as complex an object as you wish var messageObj = { type: 'complex', params: { foo: 'bar', subObj: { hello: 'world', name: 'rob' }, arr: ['a', 'b', 'c'] } }; EWD.send(messageObj, callbackFn); At back-end: var name = messageObj.params.subObj.name;
  • 7. Copyright © 2016 M/Gateway Developments Ltd Sending complex messages • Params can be as complex an object as you wish var messageObj = { type: 'complex', params: { foo: 'bar', subObj: { hello: 'world', name: 'rob' }, arr: ['a', 'b', 'c'] } }; EWD.send(messageObj, callbackFn); At back-end: var b = messageObj.params.arr[1];
  • 8. Copyright © 2016 M/Gateway Developments Ltd Returning Complex Responses • The response object returned by the back- end handler's send() or finished() functions can be as complex as you want • Be careful with the response size: – Can significantly slow down ewd-qoper8 – The larger the response, the longer it takes for Express to return it to the browser or client
  • 9. Copyright © 2016 M/Gateway Developments Ltd Returning Complex Responses finished({ foo: 'bar', myObj: { hello: 'world', name: 'Rob' } myArr: ['a','b','c'] });
  • 10. Copyright © 2016 M/Gateway Developments Ltd Returning Complex Responses finished({ foo: 'bar', myObj: { hello: 'world', name: 'Rob' } myArr: ['a','b','c'] }); Accessed in browser-side response handler as: responseObj.message.myObj.name In both EWD.send()'s callback and Pub/Sub handler