Repository navigation
Expand file tree
/
Copy pathTwitterServer.h
More file actions
49 lines (41 loc) · 1.75 KB
/
Copy pathTwitterServer.h
File metadata and controls
49 lines (41 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*###############################
# FH Salzburg #
# WS2010 MMT-B2009 #
# Multimediale Netzwerke #
# Uebungsprojekt #
# Fritsch Andreas, Hanli Ismail #
# Sun, 28.11.2010 22:00 #
###############################*/
#ifndef TWITTERSERVER_H_INCLUDED
#define TWITTERSERVER_H_INCLUDED
#include <fstream>
#include "MultiplexingServer.h"
#define LOGFILEPATH "logfile.txt" // our logfile
using namespace std;
class TwitterServer:MultiplexingServer // server is derived from our multiplexing server
{
public:
TwitterServer(const unsigned short port = 3000);
~TwitterServer();
void setupServer(const unsigned short port = 3000);
void run(void);
private:
map<SOCKET, string> tweeter; // this map saves the tweeter socket and name
multimap<string, string> tweet; // this multimap saves the tweets by socket and content
multimap<string, string> abonnement; // this multimap saves who is followed by whom
//Helper methods
SOCKET getSocketByTweeter(const string name);
void getOtherTweets(const SOCKET clientSocket);
void getAllTweets(const SOCKET clientSocket);
void getOwnTweets(const string nameOfTweeter, const SOCKET clientSocket);
void sendToFollowers(const SOCKET clientSocket, const string message);
void followTweeter(const SOCKET follower, const string followedTweeter);
void commandInterpreter(char* command[], const SOCKET clientSocket);
bool loggedIn(const SOCKET clientSocket);
void newTweet(const SOCKET clientSocket, const string text);
void makeSubString(char* command[]);
void logInTweeter(const SOCKET clientSocket, const string name);
void logOutTweeter(const SOCKET clientSocket);
void sendNameOfTweeter(const SOCKET clientSocket);
};
#endif // TWITTERSERVER_H_INCLUDED