Starting from:
$35

$29

Homework 2 - Bulletin Board System: Part 2 Solution

Description

Continuing the first part, you are asking to implement the functions of the Bulletin Board System (BBS) server.


Requirement

The service accepts the following commands and at least 10 clients:

When client enter command incompletely E.g., missing parameters, the server should show command format for client.

Command format
Description


Result






create-board <name>
Create a board which named <name>.
Success

Create board successfully.

<name> must be unique.






If Board's name is already used, show failed







Fail (1)

Board already exist.








message, otherwise it is success.






Must be logged in when creating board’s







Fail (2)

Please login first.








name










create-post <board-name> --title <title>
Create a post which title is <title> and content
Success

Create post successfully.
--content <content>
is <content>.












(command is in the same line )
Use --title and --content to separate titles and







Fail (1)

Board does not exist.

content.











<tilte> can have space but only in one line.







Fail (2)

Please login first.


<content> can have space, and key in <br> to












indicate a new line.











list-board ##<key>
List all boards in BBS.
Index
Name
Moderator

<key> is a keyword, use ## <key> to do
<Index1>    <Name1>    <Moderator1>








advanced query.












list-post <board-name> ##<key>
List all posts in a board named <board-name>
Success





<key> is a keyword, use ## <key> to do







ID
Title
Author
Date

advanced query.






<ID1>
<Title1>
<Author1>
<Date1>













Fail

Board does not exist.







read <post-id>
Show the post which ID is <post-id>.
Success

Author
:<Author1>












Title
:<Title1>





Date
:<Date1>





--






<content>





--






<User1> : <Comment1>








Fail

Post does not exist.







delete-post <post-id>
Delete the post which ID is <post-id>.
Success

Delete successfully.


Only the post owner can delete the post.







Fail (1)

Please login first.


If the user is not the post owner, show failed












message, otherwise it is success.







Fail (2)

Post does not exist.















Fail (3)

Not the post owner.








update-post <post-id> --title/content
Update the post which ID is <post-id>.
Success
Update successfully.
<new>
Use -- to decide which to modify, title or




Fail (1)
Please login first.





content, and replaced by <new>.



Only the post owner can update the post.




Fail (2)
Post does not exist.

If the user is not the post owner, show failed







message, otherwise it is success.




Fail (3)
Not the post owner.








comment <post-id> <comment>
Leave a comment < comment > at the post
Success
Comment successfully.

which ID is <post-id>




Fail (1)
Please login first.










Fail (2)
Post does not exist.

exit

Close connection.




Scenario


bash$ telnet 127.0.0.1 7890

********************************

** Welcome to the BBS server. **


    • create-board NP_HW Please login first.

    • register Bob bob@qwer.asdf 123456 Register successfully.

    • register Sam sam@qwer.com 654321 Register successfully.

    • login Bob 123456

Welcome, Bob.

    • create-board NP_HW Create board successfully.

    • create-board NP_HW Board already exist.

    • create-board OS_HW Create board successfully.

    • create-board FF

Create board successfully.

    • list-board

Index
Name
Moderator
1
NP_HW
Bob
2
OS_HW
Bob
3
FF_HW
Bob

    • list-board ##HW

Index
Name
Moderator
1
NP_HW
Bob
2
OS_HW
Bob

    • create-post NCTU --title About NP HW_2 --content Help!<br>I have some problem! Board does not exist.

    • create-post NP_HW --title About NP HW_2 --content Help!<br>I have some problem! Create post successfully.

    • create-post NP_HW --title HW_3 --content Ask!<br>Is NP HW_3 Released?


    • list-post NP


    • list-post NP_HW






    • list-post NP_HW ##HW_2




    • read 888



% read 1

Author    :Bob

Title    :About NP HW_2

Date    :2020-03-31

--

Help!


--

    • update-post 888 --title NP HW_2 Post does not exist.

    • update-post 1 --title NP HW_2 Update successfully.

    • read 1

Author    :Bob

Title    :NP HW_2

Date    :2020-03-31

--




--

    • logout Bye, Bob.

    • login Sam 654321 Welcome, Sam.

    • update-post 1 --content Ha!<br>ha!<br>ha! Not the post owner.

    • delete-post 1


    • comment 888 Ha! ha! ha! Post does not exist.

    • comment 1 Ha! ha! ha! Comment successfully.

    • read 1






--




--


    • create-board Hello Create board successfully.

    • list-board

Index
Name
Moderator
1
NP_HW
Bob
2
OS_HW
Bob
3
FF_HW
Bob
4
Hello
Sam

    • logout Bye, Sam.

    • login Bob 123456 Welcome, Bob.

    • delete-post 1 Delete successfully.

    • read 1

Post does not exist.

    • logout Bye, Bob.
    • exit

Grade (100%)

create-board command. - (10%) create-post command. - (20%) list-board command. - (15%)

list-post command. - (15%) read command. - (10%)

delete-post command. - (10%) update-post command. - (10%) comment command. - (10%)


Submission

Please upload a zip file called “hw2_{$student_id}.zip” that includes your source code. Submission that don’t follow the rule will get 20% punishment on the grade.

You will get 0 points on this project for plagiarism. Please don’t copy-paste any code!

Note


You will be asked to use AWS resources in projects 3 and 4, so we suggest you use AWS SDK supported languages to implement this project.

Reference

    1. C/C++ Socket

    2. SQLite C/C++ Interface

    3. Linux socket SELECT

    4. AWS SDK supported languages

More products