
**CoapClient (interface):** describes interfaces that must be supported by a client
**Client:** individual implementation of a client application, implements CoapClient (interface)
**ChannelManager:** manages channels
**Channel:** one channel represents a connection to one client
**CoapClient:** Interface that must be implemented by a client
**Client:** Customized implementation of a client application, implements `CoapClient`
**Channel:** A channel represents a connection between a Client and a Server
**ChannelManager:** Manages `Channels` (Timeouts, Matching Requests and Responses)
#### Server Side

**CoapResource (interface):** describes interfaces that must be supported by each resource.
**BasicCoapResource:** already implemented resource with basic functionality, implements CoapResource (interface)
**TemperatureResource:** individual resource, inherits from BasicCoapResource
**CoapServer (interface):** describes interfaces that must be supported by a resource server
**CoapResourceServer:** manages a list of resources, enables access of these resources from outside, implements CoapServer (interface)
**Server:** individual implementation of a server application, creates CoapResourceServer and resources
* ToDo on server side:
1. Create a new resource class TemperatureResource
2. Instantiate a new ResourceServer
3. Instantiate a new TemperatureResource
4. Add the TemperatureResource to the ResourceServer
5. Run the ResourceServer
* ToDo on client side:
1. Establish a connection to the Server using the ChannelManager
2. Create a CoapRequest & add some Options
3. Send the CoapRequest
4. Wait for CoapResponse
5. Print the CoapResponse on the console
**CoapResource:** Interface that must be supported by each resource.
**BasicCoapResource:** Already implemented resource with basic functionality, implements `CoapResource`
**TemperatureResource:** Example of a customized resource, inherits from `BasicCoapResource`
**CoapServer:** Interface that must be supported by a resource server
**CoapResourceServer:** Manages a list of resources, enables access of these resources from outside, implements `CoapServer`
**Server:** Example of a customized implementation of a server application, creates `CoapResourceServer` and `CoapResources`
## 4. Import of prepared project into Eclipse
You can find the required files in our repository at https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap/tree/master/ws4d-jcoap-handsOn
You can find the required files in our repository at [https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap/tree/master/ws4d-jcoap-handsOn](https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap/tree/master/ws4d-jcoap-handsOn)
3. Implement an Air Conditioner Resource with the path “/ACControl”, that can be set to “high”, “medium”, “low” or “off” (Client.java & Server.java, TODO 12-15):
```java
while(true){
try{Thread.sleep(5000);}
catch(InterruptedExceptione){/*do nothing*/}
resource.changed();
}
```
3. Implement an Air Conditioner Resource with the path `/ACControl`, that can be set to `high`, `medium`, `low` or `off` (Client.java & Server.java, TODO 12-15):
* Change exitAfterResponse to false (Client.java, TODO 12)
* Add the observe-option to your CoAP-GET request (Client.java, TODO 13)
`request.setObserveOption(0);`
* add a BasicCoapResource to the ResourceServer (Server.java, TODO 14) `resourceServer.createResource(newBasicCoapResource(“/ACControl”,”off”,CoapMediaType.text_plain));`
```java
request.setObserveOption(0);
```
* add a BasicCoapResource to the ResourceServer (Server.java, TODO 14)