Skip to content
Snippets Groups Projects
Commit 559494e9 authored by jdkruege's avatar jdkruege
Browse files

Cleaned up Service and Source files.

parent c75f4917
No related branches found
No related tags found
No related merge requests found
#include "Service.h"
Service::Service(int id, string name, double frequency)
{
_id = id;
_name = name;
_frequency = frequency;
}
Service::Service(int id, string name, double frequency) : _id(id), _name(name), _frequency(frequency) {}
ServiceInfo Service::info()
{
......
......@@ -2,95 +2,12 @@
#include <iostream>
#include <string>
#include "Client.h"
#include "Server.h"
#include "Capsule.h"
#include "LSM9DS0.h"
using namespace std;
using namespace Client;
using namespace Server;
void clientSide()
{
string address;
bool stop = false;
string message = "";
cout << "MAC Address I need to connect to: ";
cin >> address;
if (!Client::cInit(address))
{
cout << "That address is not properly formatted." << endl;
return;
}
Client::cConnect();
cout << "Please input your message, if you would like to stop type \"STOP\"" << endl;
while (Client::cCheckStatus() && !stop)
{
getline(cin, message);
Capsule cap = Capsule(message);
if (message.compare("STOP") == 0) stop = true;
Client::cSendMessage((string)((char*)&cap));
}
if (!Client::cCheckStatus())
{
perror("Oh no!");
}
Client::cDisconnect();
cout << "Shutting Client Down" << endl;;
return;
}
void serverSide()
{
bool stop = false;
string message = "";
Server::sInit();
message = Server::sListen();
cout << message + " has connected to the server" << endl;
while (!stop)
{
message = Server::sReadMessage();
Capsule cap = (Capsule&)(*message.c_str());
//if (message.compare("STOP") == 0) stop = true;
/*else*/ cout << cap.WhatDoIHave() << endl;
}
Server::sDisconnect();
cout << "Shutting Server Down." << endl;
return;
}
int main(int argc, char **argv)
{
string choice;
cout << "Would you like to be Client or Server? ";
cin >> choice;
if (choice.compare("Client") == 0) clientSide();
else if (choice.compare("Server") == 0) serverSide();
else cout << "Wrong choice" << endl;
cout << "Closing program now." << endl;
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment