-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Wilson Ko
committed
Jul 5, 2012
1 parent
484f599
commit 232aff7
Showing
8 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|