mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-25 13:38:35 -05:00
Feature/thesis work merge (#566)
Web GUI from Klas Eskilson (three new modules: webgui, webbrowser and cefwebgui) Parallel connection refactorization Wormhole server added to the main repository Transfer function editor work from Cristoffer Särevall Update ghoul
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H
|
||||
|
||||
#include <ctime>
|
||||
#include <ext/json/json.hpp>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "topic.h"
|
||||
#include "connection.h"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class AuthorizationTopic : public Topic {
|
||||
public:
|
||||
AuthorizationTopic();
|
||||
~AuthorizationTopic() {};
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone();
|
||||
|
||||
/* https://httpstatuses.com/ */
|
||||
static const struct Statuses {
|
||||
enum StatusCode {
|
||||
OK = 200,
|
||||
Accepted = 202,
|
||||
|
||||
BadRequest = 400,
|
||||
Unauthorized = 401,
|
||||
NotAcceptable = 406,
|
||||
|
||||
NotImplemented = 501
|
||||
};
|
||||
};
|
||||
private:
|
||||
bool _isAuthenticated;
|
||||
|
||||
const std::string getKey() const;
|
||||
bool authorize(const std::string key);
|
||||
nlohmann::json message(const std::string &message, const int &statusCode = Statuses::NotImplemented);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H
|
||||
@@ -0,0 +1,79 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODOULES_SERVER__CONNECTION_H
|
||||
#define OPENSPACE_MODOULES_SERVER__CONNECTION_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <ghoul/io/socket/tcpsocketserver.h>
|
||||
#include <ghoul/io/socket/websocketserver.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
#include <ext/json/json.hpp>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <fmt/format.h>
|
||||
#include <include/openspace/engine/openspaceengine.h>
|
||||
#include <include/openspace/engine/configurationmanager.h>
|
||||
|
||||
#include "topic.h"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
using TopicId = size_t;
|
||||
|
||||
class Connection {
|
||||
public:
|
||||
Connection(std::shared_ptr<ghoul::io::Socket> s, const std::string &address);
|
||||
|
||||
void handleMessage(std::string message);
|
||||
void sendMessage(const std::string& message);
|
||||
void handleJson(nlohmann::json json);
|
||||
void sendJson(const nlohmann::json& json);
|
||||
void setAuthorized(const bool status);
|
||||
|
||||
bool isAuthorized();
|
||||
|
||||
|
||||
std::shared_ptr<ghoul::io::Socket> socket();
|
||||
std::thread& thread();
|
||||
void setThread(std::thread&& thread);
|
||||
|
||||
private:
|
||||
ghoul::TemplateFactory<Topic> _topicFactory;
|
||||
std::map<TopicId, std::unique_ptr<Topic>> _topics;
|
||||
std::shared_ptr<ghoul::io::Socket> _socket;
|
||||
std::thread _thread;
|
||||
|
||||
std::string _address;
|
||||
bool _requireAuthorization;
|
||||
bool _isAuthorized;
|
||||
std::map <TopicId, std::string> _messageQueue;
|
||||
std::map <TopicId, std::chrono::system_clock::time_point> _sentMessages;
|
||||
|
||||
bool isWhitelisted();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODOULES_SERVER__CONNECTION_H
|
||||
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_SERVER___CONNECTIONPOOL___H__
|
||||
#define __OPENSPACE_MODULE_SERVER___CONNECTIONPOOL___H__
|
||||
|
||||
#include <ghoul/io/socket/socketserver.h>
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ConnectionPool {
|
||||
public:
|
||||
ConnectionPool(std::function<void(std::shared_ptr<ghoul::io::Socket> socket)> handleSocket);
|
||||
~ConnectionPool();
|
||||
void addServer(std::shared_ptr<ghoul::io::SocketServer> server);
|
||||
void removeServer(ghoul::io::SocketServer* server);
|
||||
void clearServers();
|
||||
void updateConnections();
|
||||
|
||||
private:
|
||||
|
||||
void disconnectAllConnections();
|
||||
std::mutex _connectionMutex;
|
||||
void removeDisconnectedSockets();
|
||||
void acceptNewSockets();
|
||||
|
||||
std::function<void(std::shared_ptr<ghoul::io::Socket>)> _handleSocket;
|
||||
std::vector<std::shared_ptr<ghoul::io::SocketServer>> _socketServers;
|
||||
std::vector<std::shared_ptr<ghoul::io::Socket>> _sockets;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_SERVER___CONNECTIONPOOL___H__
|
||||
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H
|
||||
|
||||
#include <openspace/query/query.h>
|
||||
#include "topic.h"
|
||||
#include "connection.h"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class GetPropertyTopic : public Topic {
|
||||
public:
|
||||
GetPropertyTopic();
|
||||
~GetPropertyTopic() {};
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone();
|
||||
|
||||
private:
|
||||
nlohmann::json getAllProperties();
|
||||
nlohmann::json getPropertyFromKey(const std::string& key);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__JSON_CONVERTERS_INL
|
||||
#define OPENSPACE_MODULES_SERVER__JSON_CONVERTERS_INL
|
||||
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <ext/json/json.hpp>
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace openspace::properties {
|
||||
|
||||
void to_json(json &j, const Property &p);
|
||||
void to_json(json &j, const Property* pP);
|
||||
void to_json(json &j, const PropertyOwner &p);
|
||||
void to_json(json &j, const PropertyOwner *p);
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void to_json(json &j, const SceneGraphNode &n);
|
||||
void to_json(json &j, const SceneGraphNode* pN);
|
||||
|
||||
void to_json(json &j, const Renderable &r);
|
||||
void to_json(json &j, const Renderable* pR);
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
namespace glm {
|
||||
|
||||
void to_json(json &j, const dvec3 &v);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H
|
||||
|
||||
#include <ext/json/json.hpp>
|
||||
#include <modules/server/include/topic.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class LuaScriptTopic : public Topic {
|
||||
public:
|
||||
LuaScriptTopic() : Topic() {};
|
||||
~LuaScriptTopic() {};
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone() { return true; };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H
|
||||
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H
|
||||
|
||||
#include <ext/json/json.hpp>
|
||||
#include <modules/server/include/topic.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SetPropertyTopic : public Topic {
|
||||
public:
|
||||
SetPropertyTopic() : Topic() {};
|
||||
~SetPropertyTopic() {};
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone() { return true; };
|
||||
|
||||
private:
|
||||
void setTime(const std::string& value);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H
|
||||
@@ -0,0 +1,52 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H
|
||||
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include "topic.h"
|
||||
#include "connection.h"
|
||||
|
||||
namespace openspace {
|
||||
class property;
|
||||
class SubscriptionTopic : public Topic {
|
||||
public:
|
||||
SubscriptionTopic();
|
||||
~SubscriptionTopic();
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone();
|
||||
|
||||
private:
|
||||
bool _requestedResourceIsSubscribable;
|
||||
bool _isSubscribedTo;
|
||||
int _onChangeHandle;
|
||||
int _onDeleteHandle;
|
||||
properties::Property* _prop;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H
|
||||
@@ -0,0 +1,50 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__TIME_TOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__TIME_TOPIC_H
|
||||
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include "topic.h"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class TimeTopic : public Topic {
|
||||
public:
|
||||
TimeTopic();
|
||||
~TimeTopic();
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone();
|
||||
private:
|
||||
nlohmann::json currentTime();
|
||||
nlohmann::json deltaTime();
|
||||
|
||||
int _timeCallbackHandle;
|
||||
int _deltaTimeCallbackHandle;
|
||||
std::chrono::system_clock::time_point _lastUpdateTime;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__TIME_TOPIC_H
|
||||
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__TOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__TOPIC_H
|
||||
|
||||
#include <ext/json/json.hpp>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Connection;
|
||||
|
||||
class Topic {
|
||||
public:
|
||||
Topic() {};
|
||||
virtual ~Topic() {};
|
||||
void initialize(Connection* connection, size_t topicId);
|
||||
nlohmann::json wrappedPayload(const nlohmann::json &payload) const;
|
||||
nlohmann::json wrappedError(std::string message = "Could not complete request.", int code = 500);
|
||||
virtual void handleJson(nlohmann::json json) = 0;
|
||||
virtual bool isDone() = 0;
|
||||
|
||||
protected:
|
||||
size_t _topicId;
|
||||
Connection* _connection;
|
||||
};
|
||||
|
||||
class BounceTopic : public Topic {
|
||||
public:
|
||||
BounceTopic() : Topic() {};
|
||||
~BounceTopic() {};
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone() { return false; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__TOPIC_H
|
||||
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H
|
||||
#define OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H
|
||||
|
||||
#include <ext/json/json.hpp>
|
||||
#include <modules/server/include/topic.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class TriggerPropertyTopic : public Topic {
|
||||
public:
|
||||
TriggerPropertyTopic() : Topic() {};
|
||||
~TriggerPropertyTopic() {};
|
||||
void handleJson(nlohmann::json json);
|
||||
bool isDone() { return true; };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H
|
||||
Reference in New Issue
Block a user