---
# System prepended metadata

title: Socket App

---

# Socket App

## SPECS
I had comeup with the following specification.

:::warning
  STILL NEED REFINING
:::

### SPEC 1: task activity
```
// project*room
// task activity*message
		// ROOM: 
				// background_update_projects@project_id
				// watched_tasks@task_id
		// MESSAGE:
				// task_id
				// project_id
				// kind activity
				// idepotency_key
// message(task activity) -> room(project)
```

### SPEC 2: user citation comment
```
		// ROOM:
			// quoted_users@user_id
		// MESSAGE:
				// task_id
				// position [comment, description, assign]
				// idepotency_key
// user
// citation -> user
````
### SPEC 3: subscriptions
```
	// LOAD PROJECT -> background_update_projects@project_id
	// WATCH TASK -> watched_tasks@task_id
	// LOGIN -> quoted_users@user_id
````

### SPEC 4: unsubscriptions
```
	// UNWATCH TASK <- watched_tasks@task_id
	// CLOSE PROJECT <- background_update_projects@project_id
	// LOGOUT <- quoted_users@user_id
````
## ROADMAP
 0. [ ] Lab
     1. [x] socket with one room
     2. [ ] webclient connected
     3. [x] nodeclient connected
     4. [ ] nodeclient send a message to webclient
 2. [ ] background_update_projects
    1. [x] socket app - build from the ground up
         1. [x] create room
         1. [x] subscribe to room when open a project
         1. [x] unsubscribe to room when close a project
         1. [x] receive message with task activity
         1. [x] broadcast message to channel `background_update_projects@project_id`
    1. [ ] crud api - add client on crud api
         1. [x] add service websocket
         2. [x] on update project broadcast 
         3. [ ] on update task broadcast
         4. [ ] on create task broadcast
         5. [ ] on delete task broadcast
    1. [ ] add client on frontend
         1. [x] add service websocket
         1. [x] subscribe on open project
         1. [ ] handle update with rxjs update queue
         1. [ ] unsubscribe on close project
    2. [ ] create worker connected to socket 

## Reference
- [rxjs and websocket](https://rxjs-dev.firebaseapp.com/api/webSocket/webSocket)
- [rxjs and axios](https://itnext.io/working-with-axios-and-rxjs-to-make-simple-ajax-service-module-6fda9ecdaf9f)
- [redis to scaling up hubs](https://hackernoon.com/communicating-go-applications-through-redis-pub-sub-messaging-paradigm-df7317897b13)

