- Clone repository and install dependencies
$ git clone https://github.com/ndom91/netcat-comments.git
$ cd netcat-comments
$ corepack enable
$ pnpm install
- Run development server
$ pnpm dev
You'll then have a process listening on port 5000
- Start Netcat on port
5000
$ nc localhost 5000
In this netcat process you can then send and receive messages by entering your message and pressing Enter.
Messages sent to the system have the following syntax.
<requestId>|<command>|<payload>
requestId
- Unique 7 character string matching/([a-z]{7})/
command
- One of the available commandspayload
- Command specific payload. If there are multiple fields, these will continue to be pipe (|
) delimited.
Example
> nc localhost 5000
abcdefg|SIGN_IN|nico
abcdefg
gfedcba|WHOAMI
gfedcba|nico
Signin with a supplied username as
Payload Arguments
<username>
Returns
<requestId>
- Request Id consisting of a 7-character lowercase string
Example
haskduw|SIGN_IN|nico
haskduw
Signout of supplied username
Payload Arguments
<username>
Returns
<requestId>
- Request Id consisting of a 7-character lowercase string
Example
lqkwidh|SIGN_OUT
lqkwidh
Return current username
Payload Arguments
- None
Returns
- Active
username
Example
iqibalz|WHOAMI
iqibalz|john
Create a new comment thread
Payload Arguments
<discussionUserReference>
- Discussion user reference consisting of a period delimited alphanumeric string, such asb3hsbdf.1m30s
<comment>
- Comment body, a unicode string of unspecified length
Returns
<discussionId>
- Discussion thread identifier
Example
pqjdbyx|CREATE_DISCUSSION|fghjkla.01|Hello everybody!
pqjdbyx|ef95a0d5
Return all messages on a discussion thread
Payload Arguments
<discussionId>
- Discussion Id consisting of a 7-character alphanumeric string, likedh7hs3b
Returns
<requestId>
- Request Id consisting of a 7-character lowercase string<discussionId>
- Discussion Id consisting of a 7-character alphanumeric string, likedh7hs3b
<discussionUserReference>
- Discussion user reference consisting of a period delimited alphanumeric string, such asb3hsbdf.1m30s
(<username>|<comment>)[]
- Array of all messages withusername
andcomment
Example
bajkxuj|GET_DISCUSSION|ef95a0d5
bajkxuj|ef95a0d5|fghjkla.01|(john|"Hello everybody!")
Append a reply to an existing discussion thread
Payload Arguments
<discussionId>
- Discussion Id consisting of a 7-character alphanumeric string, likedh7hs3b
<comment>
- Comment body
Returns
<requestId>
- Request Id consisting of a 7-character lowercase string
Example
hvbxnod|CREATE_REPLY|ef95a0d5|Hello back at you!
hvbxnod
Return all discussion threads and its messages
Payload Arguments
<commentReferencePrefix>
- First part of the period delimited reference, such asb3hsbdf
Returns
<requestId>
- Request Id consisting of a 7-character lowercase string<discussionId>
- Discussion Id consisting of a 7-character alphanumeric string, likedh7hs3b
<discussionUserReference>
- Discussion user reference consisting of a period delimited alphanumeric string, such asb3hsbdf.1m30s
(<username>|<comment>)[]
- Array of all messages withusername
andcomment
Example
bakxufh|LIST_DISCUSSIONS|fghjkla
bakxufh|(72bdabe3|fghjkla.02|(john|"Hey there")),(ef95a0d5|fghjkla.01|(bob|"Hello back at you!",nico|"Hey team"))
MIT