Skip to content
Permalink
Browse files
added labs
  • Loading branch information
aa7401 committed Oct 19, 2018
1 parent 15a693b commit 89a3f9c5f679fa7ca93314e04a4eb2b4169ec40d
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 69 deletions.
@@ -3,6 +3,68 @@

This worksheet builds on the **Publish Subscribe** one. Make sure you have finished this before starting. In this worksheet you will learn how to use the TDD methodology to develop websites that subscribe to MQTT brokers. You can find the exercise files in the `exercises/02_tdd/web_client/` directory.

## 1 Publish Subscribe

Up to this point all the activities have been using the **HTTP Protocol**, which uses a _request-response_ process (the client requests a resource and the server responds with this resource). If this seems unfamiliar you should work through the HTTP Protocol worksheet.

Whilst this approach works fine for delivering content to a web browser it is not a useful approach for certain applications. Imagine a chat room where you had to refresh the page to view new messages.

In this worksheet you will learn how to use a new HTML5 **websocket** protocol that allows a full duplex (2 way) communication over a single TCP connection. We will then explore the **MQTT** protocol which can be run over websockets and is used to implement a _push message_ system, technically called _publish-subscribe_.

### 1.1 Set Up

Start by installing the [Mosquitto Tools](https://www.eclipse.org/mosquitto/download/).

If you are using MacOS you should install the [Brew Package Manager](https://brew.sh) and use this to install Mosquitto using `brew install mosquitto`.

If you are using Ubuntu you can install using`sudo apt install mosquitto`. This also works for most online IDEs.

```
mosquitto_sub -h test.mosquitto.org -t "#" -v
```

If you are using Windows 10 you can download the 64 bit Binary exe and install.

## 2 The MQTT Protocol

Now we have the tools installed we can start using the protocol. You have installed 2 tools, `mosquitto_pub` is used to publish messages and `mosquitto_sub` subscribes to a channel. We will use the `test.mosquitto.org` broker.

Start by opening _two_ terminal windows:

In the first window we will run the `mosquitto_sub` command and subscribe to a _topic_ called `302CEM/XXX` where `XXX` is your university username.

```shell
$ mosquitto_sub -h test.mosquitto.org -t 302CEM/XXX
```

1. The `-h` flag allows us to specify the _host_, in this case `test.mosquitto.org`.
2. The `-t` flag allows us to specify the _topic_, in this case `205CDE/XXX` (remember to substitute your username)

In the second terminal we will run the `mosquitto_pub` command to publish messages to our topic.

```shell
$ mosquitto_pub -h test.mosquitto.org -t 302CEM/XXX -m 'hello world'
```

1. The `-h` flag allows us to specify the _host_, in this case `test.mosquitto.org`.
2. The `-t` flag allows us to specify the _topic_, in this case `205CDE/XXX` (remember to substitute your username)
3. The `-m` flag allows us to specify the _message_, in this case `hello world`.

If you look at the first terminal window (running `mosquitto_sub`) you should see your message displayed.

### 2.1 Test Your Understanding

Working in small groups of between 2 and 4 people:

1. Decide on the _topic name_ you will use.
2. Everyone runs the `mosquitto_sub` tool and subscribes to this same topic.
3. Each person launches a new terminal in a new pane (so you can see both terminal windows).
4. use the `mosquitto_pub` tool to send a message to your chosen _topic name_.
5. Look at the output of your `mosquitto_sub` command (in the first terminal window).

What have you produced? Can you think of any application for this...


## 1 Basic MQTT Client

In this first exercise you will learn the basics of how to create a website that can subscribe to data from an MQTT broker. It will focus on writing JavaScript code that runs _inside the browser_. Open the `chat/` directory where you will see three files plus a directory.

This file was deleted.

@@ -0,0 +1,9 @@

# Domain-Driven Design

In this lab you will be exploring the software domain for your assignment scenario. By the end of the lab you will have build a detailed model of the domain to that shows your understanding. This should include:

1. The artefacts that make up the domain
2. The technical language around the domain.

This activity should be carried out in teams comprising other students who have been assigned the same topic. You should make use of the lab supervisor as a domain expert.
@@ -28,26 +28,27 @@ There are two labs to complete and you should aim to get both completed in the f
1. Templates and Forms
2. Dynamic Websites

The extension lab covers the use of advanced async features to reduce the complexity of your code and improve legibility.

### 2 Test-Driven Development

[Lecture Slides](https://drive.google.com/open?id=14lBIsoru7s4qwpVGa6hhd1Iq1ezXSvZYk38RSNAZT50)

In this week we will be extending your understanding of ECMA6 by learning how to apply the principles of Test-Driven Development (TDD) when writing code in the ECMA6 programming language. You will be required to complete two labs this week:
In this week we will be extending your understanding of ECMA6 by learning how to apply the principles of Test-Driven Development (TDD) when writing code in the ECMA6 programming language. You will be required to complete the **TDD Express** lab this week. There are two additional labs that you should be attempting if time allows.

1. TDD Express
2. TDD API
1. TDD API
2. TDD for Browser JS using the MQTT protocol

### 3 Domain-Driven Design
### 3 Software Design

[Lecture Slides](https://drive.google.com/open?id=15roChBN5xnttLZYg7Wdk7b26W5Q23nCYNycLj8GNy5w)
At this stage you will have been assigned to an assignment topic and will apply the Domain-Driven Design (DDD) techniques to build a domain model and use this to explore alternative architectures. This will form part of your assignment submission. If you have time you will be able to continue your ECMA6 learning. There are two labs in this section, each taking a week to complete:

At this stage you will have been assigned to an assignment topic and will apply the Domain-Driven Design (DDD) techniques to build a domain model. This will form part of your assignment submission. If you have time you will be able to continue your ECMA6 learning.
1. Domain-Driven Design
2. Software Architecture

### 4 Software Architecture

[Lecture Slides](https://drive.google.com/open?id=1Ux83hzw-DdcBWn6PUXz_xF3b-ytE4PsWLpSKS_dqBfw)

Now you will be expected to use your understanding to produce three different architectural designs based on your domain model and evaluate these to identify the best.
--------

## 5 Architectural Coupling

0 comments on commit 89a3f9c

Please sign in to comment.