Commit 7c3b75de authored by legoc's avatar legoc
Browse files

added missing files

parent 75d6ed62
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "InvalidArgumentException.h"
namespace cameo {
InvalidArgumentException::InvalidArgumentException(const std::string& message) :
RemoteException(message) {
}
}
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef CAMEO_INVALIDARGUMENTEXCEPTION_H_
#define CAMEO_INVALIDARGUMENTEXCEPTION_H_
#include "RemoteException.h"
namespace cameo {
class InvalidArgumentException : public RemoteException {
public:
InvalidArgumentException(const std::string& message);
};
}
#endif
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "SocketException.h"
namespace cameo {
SocketException::SocketException(const std::string& message) :
RemoteException(message) {
}
}
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef CAMEO_SOCKETEXCEPTION_H_
#define CAMEO_SOCKETEXCEPTION_H_
#include "RemoteException.h"
namespace cameo {
class SocketException : public RemoteException {
public:
SocketException(const std::string& message);
};
}
#endif
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include "../cameo/cameo.h"
using namespace std;
using namespace cameo;
int main(int argc, char *argv[]) {
try {
Server server("tcp://bad:7000");
server.isAvailable(1000);
}
catch (SocketException const & e) {
cout << "Socket exception: " << e.what() << endl;
}
catch (exception const & e) {
cout << "The server has bad endpoint" << endl;
}
try {
Server server("tcp//bad:7000");
server.isAvailable(1000);
}
catch (exception const &) {
cout << "The server has bad endpoint" << endl;
}
return 0;
}
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include "../cameo/cameo.h"
#include <boost/shared_ptr.hpp>
using namespace std;
using namespace boost;
using namespace cameo;
struct StopData {
bool stop;
StopData() : stop(false) {}
};
struct Handler {
shared_ptr<StopData> data;
Handler(shared_ptr<StopData> sharedData) : data(sharedData) {}
void operator()(bool available) {
if (available) {
cout << "server is available" << endl;
}
else {
cout << "server is not available" << endl;
data->stop = true;
}
}
};
int main(int argc, char *argv[]) {
application::This::init(argc, argv);
// The start function must be called into a block to ensure the destructor of Instance is called before This::terminate()
{
Server server("tcp://localhost:9000");
server.setTimeout(1000);
shared_ptr<StopData> data(new StopData());
auto_ptr<ConnectionChecker> ConnectionChecker = server.createConnectionChecker(Handler(data), 1000);
while (!data->stop) {
sleep(1);
}
}
application::This::terminate();
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment