Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write in c++, more directions are at the bottom. Shouldn't be that hard just a little stuck. Can you please provide the code in

Please write in c++, more directions are at the bottom. Shouldn't be that hard just a little stuck.

image text in transcribed

image text in transcribed

image text in transcribed

Can you please provide the code in C++ with comments where needed? I would like to see someone else's take at how to solve. thank you.

In this project you will simulate a system of n users, each of which is connected to an online social networking service TWEETER via a streamer using a total of n 2 threads: one thread for each user, and one each for TWEETER and the streamer Each thread simulating user, 0Sin-1, executes a sequence of commands found in the text file useri.txt corresponding to its user number i. Valid commands include . Handle @useri, where user, is a character string of maximum length 20 alphabetic characters representing user i's handle. The Handle command is always the first command in the file and only occurs once Start #tag, where tag is a character string of maximum length 20 alphabetic characters representing the topic of the tweet. The text that follows this command until the End command make up the contents of the tweet from user, with hashtag # tag. The tweet may be up to 140 characters in length, and may span multiple lines; i begins on the line following the Start command. The tweet is to be streamed to TWEETER via the streamer. If the tweet spans multiple lines, then each line must be streamed separately. A user's input file may include multiple instances of tweets with the same #tag and/or tweets with other tags. End #tag, indicates the end of the tweet with tag # tag; the Start and End commands always come in rs with matching tags ? Follow #tag, causes TWEETER to transfer complete tweets that have been streamed to it matching the tag to be streamed to the user making the request. TWEETER must therefore maintain a repository of tweets organized by #tag. Further, it is required to stream tweets on topic #tag to all users that are following this #tag. Not only must TWEETER keep track of which users following a #tag but also which tweets with this #tag have been received by each user. If a new tweet with # tag is streamed to TWEETER, it must in turn interact with the streamer thread to stream the tweet to all users following this #tag when it next interacts with the each one If there is no match at TWEETER to the tag, a message to that effect should be returned. A user's input file may include any number of Follow commands. . Read, the user pauses for a (short) random amount of time; this simulates time to read tweets. A user's input file may include any number of Read commands . Exit, indicates that there are no more commands for this user to execute, i.e., user i logs off TWEETER. Thus the thread simulating the user should terminate gracefully For example, if useri finds the following command sequence in useri.txt it would set it's handle to @happy, stream a tweet on the topic of # haiku to TWEETER, then retrieve any tweets TWEETER has on the topic of #bostonweather, pause briefly to read them, then stream another tweet on the topic of # haiku, and exit. In this project you will simulate a system of n users, each of which is connected to an online social networking service TWEETER via a streamer using a total of n 2 threads: one thread for each user, and one each for TWEETER and the streamer Each thread simulating user, 0Sin-1, executes a sequence of commands found in the text file useri.txt corresponding to its user number i. Valid commands include . Handle @useri, where user, is a character string of maximum length 20 alphabetic characters representing user i's handle. The Handle command is always the first command in the file and only occurs once Start #tag, where tag is a character string of maximum length 20 alphabetic characters representing the topic of the tweet. The text that follows this command until the End command make up the contents of the tweet from user, with hashtag # tag. The tweet may be up to 140 characters in length, and may span multiple lines; i begins on the line following the Start command. The tweet is to be streamed to TWEETER via the streamer. If the tweet spans multiple lines, then each line must be streamed separately. A user's input file may include multiple instances of tweets with the same #tag and/or tweets with other tags. End #tag, indicates the end of the tweet with tag # tag; the Start and End commands always come in rs with matching tags ? Follow #tag, causes TWEETER to transfer complete tweets that have been streamed to it matching the tag to be streamed to the user making the request. TWEETER must therefore maintain a repository of tweets organized by #tag. Further, it is required to stream tweets on topic #tag to all users that are following this #tag. Not only must TWEETER keep track of which users following a #tag but also which tweets with this #tag have been received by each user. If a new tweet with # tag is streamed to TWEETER, it must in turn interact with the streamer thread to stream the tweet to all users following this #tag when it next interacts with the each one If there is no match at TWEETER to the tag, a message to that effect should be returned. A user's input file may include any number of Follow commands. . Read, the user pauses for a (short) random amount of time; this simulates time to read tweets. A user's input file may include any number of Read commands . Exit, indicates that there are no more commands for this user to execute, i.e., user i logs off TWEETER. Thus the thread simulating the user should terminate gracefully For example, if useri finds the following command sequence in useri.txt it would set it's handle to @happy, stream a tweet on the topic of # haiku to TWEETER, then retrieve any tweets TWEETER has on the topic of #bostonweather, pause briefly to read them, then stream another tweet on the topic of # haiku, and exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions