Skip to content

Commit

Permalink
Added ascii logo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilson Ko committed Jul 5, 2012
1 parent 484f599 commit 232aff7
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 3 deletions.
5 changes: 4 additions & 1 deletion server/include/Download.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ enum Status {
STATUS_SIZE,
};


/**
* Data structure to store all data regarding swift downloads.
* Makes use of swift methods.
*/
class Download {
protected:
/// Mutex to prevent download thread and main thread from accessing same data at the same time.
Expand Down
4 changes: 4 additions & 0 deletions server/include/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#define UNLIMITED_SPEED 0

/**
* Manages all up- and downloads.
* Also responsible for playing streams.
*/
namespace DownloadManager {

struct Amount {
Expand Down
4 changes: 4 additions & 0 deletions server/include/HttpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "swift.h"
#include "Settings.h"

/**
* Http request handler.
* Acts as controller of the webserver subsystem.
*/
namespace HttpServer {

static void sendXMLResponse(std::string msg, struct evhttp_request *req, struct evbuffer *buf);
Expand Down
6 changes: 4 additions & 2 deletions server/include/SearchEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
#include "Settings.h"
#include "ticpp.h"

/**
* Interface to Dispersy module.
* Makes use of Dispersy methods to find files online.
*/
namespace SearchEngine {
/// Thread to run dispersy module in.

static pthread_t dispersy_thread;

/// Mutex to protect dispersy thread.
Expand All @@ -33,7 +36,6 @@ namespace SearchEngine {
};

void *startDispersy(void *arg);

void clearSearchResults();
std::string buildSearchXML();

Expand Down
3 changes: 3 additions & 0 deletions server/include/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#define DEFAULT_PORT 7758
#define DHT_PORT 9999

/**
* General Settings manager.
*/
namespace Settings {
/// Keeps track of the current ip address.
static std::string ip_address;
Expand Down
4 changes: 4 additions & 0 deletions server/include/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "Settings.h"
#include "swift.h"

/**
* Singleton class for downloading and binding streams.
* Makes use of swift methods.
*/
class Stream {
protected:
/// Trackers seeding this stream.
Expand Down
19 changes: 19 additions & 0 deletions server/src/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
#
# This software is written as part of the Bachelor thesis of
#
# S.E. Austin,
# A. Drif,
# W.K.H. Ko,
# J.E.T. Tan.
#
# The project was conducted at Delft University of Technology.
#
# _____ _ ______ _______ __
# / ___/ __(_) __/ //_ __/ | / /
# \__ \ | /| / / / /_/ __// / | | / /
# ___/ / |/ |/ / / __/ /_ / / | |/ /
# /____/|__/|__/_/_/ \__//_/ |___/
#
*/

#include <iostream>

#include "ticpp.h"
Expand Down
65 changes: 65 additions & 0 deletions server/src/Main.cpp~
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <iostream>

#include "ticpp.h"
#include "swift.h"
#include "DownloadManager.h"
#include "HttpServer.h"
#include "SearchEngine.h"
#include "Settings.h"

#include <stdio.h>
#include <string.h>

/**
* Define the InstallHTTPGateway method in httpgw.cpp.
*/
bool InstallHTTPGateway(struct event_base *evbase, swift::Address addr, uint32_t chunk_size, double *maxspeed);

bool InstallStatsGateway(struct event_base *evbase, swift::Address addr);

/**
* Application main loop.
*/
int main() {

// Start python binder
SearchEngine::init();

Settings::init(DEFAULT_DOWNLOAD_DIR);

// Enable pthread use in libevent.
evthread_use_pthreads();

swift::Channel::evbase = event_base_new();

evutil_socket_t sock = INVALID_SOCKET;
swift::Address bindaddress;

bindaddress = swift::Address(Settings::getIP().c_str(), 0);
bindaddress.set_port(DEFAULT_PORT);
sock = swift::Listen(swift::Address(bindaddress));

std::cout << "Listening on port " << swift::BoundAddress(sock).port() << "." << std::endl;

std::string http_address = Settings::getIP() + ":17758";

// HTTP gateway address for swift to stream.
swift::Address httpaddr = swift::Address(http_address.c_str());

double maxspeed[2] = {700*1024, 700*1024};

// Install the HTTP gateway to stream.
bool res = InstallHTTPGateway(swift::Channel::evbase, httpaddr, SWIFT_DEFAULT_CHUNK_SIZE, maxspeed);
std::cout << "HTTP gateway installation returned: " << res << std::endl;

//std::cout << "Stats gateway installation returned: " << res << std::endl;

std::cout << "Initialised swift" << std::endl;

// Set Download directory
DownloadManager::init();

// Make httpserver loop
HttpServer::init();
}

0 comments on commit 232aff7

Please sign in to comment.