Skip to content
Snippets Groups Projects
Commit b9b79d9e authored by srsdanny's avatar srsdanny
Browse files

Minor changes to networking

parent 7cd4190e
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,6 @@
<ItemGroup>
<ClCompile Include="..\..\Source\app\Application.cpp" />
<ClCompile Include="..\..\Source\app\UI.cpp" />
<ClCompile Include="..\..\Source\cache\BasicCache.cpp" />
<ClCompile Include="..\..\Source\cache\FIFOCache.cpp" />
<ClCompile Include="..\..\Source\cache\LFUCache.cpp" />
<ClCompile Include="..\..\Source\cache\LRUCache.cpp" />
......@@ -123,7 +122,6 @@
<ItemGroup>
<ClInclude Include="..\..\Source\app\Application.h" />
<ClInclude Include="..\..\Source\app\UI.h" />
<ClInclude Include="..\..\Source\cache\BasicCache.h" />
<ClInclude Include="..\..\Source\cache\Cache.h" />
<ClInclude Include="..\..\Source\cache\CacheFile.h" />
<ClInclude Include="..\..\Source\cache\FIFOCache.h" />
......
......@@ -156,9 +156,6 @@
<ClCompile Include="..\..\Source\cache\FIFOCache.cpp">
<Filter>Source Files\cache</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\cache\BasicCache.cpp">
<Filter>Source Files\cache</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Source\app\UI.h">
......@@ -269,9 +266,6 @@
<ClInclude Include="..\..\Source\cache\Cache.h">
<Filter>Header Files\cache</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\cache\BasicCache.h">
<Filter>Header Files\cache</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\cache\CacheFile.h">
<Filter>Header Files\cache</Filter>
</ClInclude>
......
......@@ -60,6 +60,10 @@ int main(int argc, char **argv) {
{
cloudFolder.assign(argv[i] + 2);
}
else if (strncmp(argv[i], "-C", 2) == 0)
{
cacheFolder.assign(argv[i] + 2);
}
}
application.cfs.getEncoder()->setFolders(dataFolder,fragFolder);
......@@ -161,7 +165,7 @@ int main(int argc, char **argv) {
cout << "To get the avaliable files enter \"getFileList\"." << endl;
cout << "To delete a file enter \"deleteFile\"." << endl;
cout << "To authorize a cloud adapter enter \"authCA\"." << endl;
cout << "To start or stop the server enter \"serverCfg\"." << endl;
cout << "To start or stop the server enter \"server\"." << endl;
}
else if (command == "addFile"){
cout << "Adding file. Please enter local file id" << endl;
......@@ -216,7 +220,7 @@ int main(int argc, char **argv) {
cin >> cloudAdapterId;
application.ui.authCloudAdapter(cloudAdapterId);
}
else if (command == "serverCfg")
else if (command == "server")
{
string startOrStop;
cout << "Start or stop server?" << endl;
......
......@@ -18,7 +18,7 @@ void FileServerConnection::run()
char buffer[100000];
string fileName;
int msgType;
char msgType;
int fileNameSize;
long long fileSize;
......@@ -51,7 +51,7 @@ void FileServerConnection::run()
// Send file
fileSize = getFileSize(file);
socket().sendBytes(&OK_ANS, sizeof(OK_ANS));
socket().sendBytes(&FILE_ANS, sizeof(FILE_ANS));
socket().sendBytes(&fileSize, sizeof(fileSize));
while (file)
{
......
......@@ -33,9 +33,13 @@ bool HomeNetworkCommunications::addFileRemote(string fileID)
refresh();
if (!piAvaliable)
{
cout << "Server not available" << endl;
return false;
}
int msgType;
char msgType;
int fileNameSize = fileID.size();
// Open file, check if exists
......@@ -87,7 +91,7 @@ ReturnableFile HomeNetworkCommunications::getFileRemote(string fileID)
return result;
}
int msgType;
char msgType;
int fileNameSize = fileID.size();
long long fileSize;
......@@ -102,7 +106,7 @@ ReturnableFile HomeNetworkCommunications::getFileRemote(string fileID)
// Get server answer
socket.receiveBytes(&msgType, sizeof(msgType));
if (msgType != OK_ANS)
if (msgType != FILE_ANS)
{
result.setErrorMessage("Serverside error");
return result;
......
......@@ -7,10 +7,11 @@
const int UDP_PORT = 42420;
const int TCP_PORT = 42421;
const int GET_CMD = 100;
const int PUT_CMD = 101;
const int OK_ANS = 200;
const int ERR_ANS = 201;
const char GET_CMD = 100;
const char PUT_CMD = 101;
const char FILE_ANS = 200;
const char OK_ANS = 201;
const char ERR_ANS = 202;
inline long long getFileSize(std::ifstream& file)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment