14#ifndef REMOTE_SERVER_H
15#define REMOTE_SERVER_H
22#include <Poco/Semaphore.h>
23#include <Poco/Net/SocketAddress.h>
24#include <Poco/Net/StreamSocket.h>
26#include "nymph_method.h"
27#include "nymph_listener.h"
28#include "nymph_logger.h"
32 std::string loggerName =
"NymphServerInstance";
33 Poco::Net::StreamSocket* socket = 0;
34 Poco::Semaphore* socketSemaphore = 0;
35 uint32_t nextMethodId = 0;
36 std::map<std::string, NymphMethod> methods;
37 std::map<uint32_t, NymphMethod*> methodIds;
38 Poco::Mutex methodsMutex;
43 NymphServerInstance(uint32_t handle, Poco::Net::StreamSocket* socket, uint32_t timeout = 3000);
46 void setHandle(uint32_t handle);
48 Poco::Semaphore* semaphore();
49 bool sync(std::string &result);
50 bool addMethod(std::string name,
NymphMethod method);
51 bool removeMethod(std::string name);
52 bool disconnect(std::string& result);
53 bool callMethod(std::string name, std::vector<NymphType*> &values,
54 NymphType* &returnvalue, std::string &result);
55 bool callMethodId(uint32_t
id, std::vector<NymphType*> &values,
NymphType* &returnvalue, std::string &result);
60 static std::map<uint32_t, NymphServerInstance*> instances;
61 static Poco::Mutex instancesMutex;
62 static uint32_t lastHandle;
64 static std::string loggerName;
65 static uint32_t nextMethodId;
68 static bool init(logFnc logger,
int level = NYMPH_LOG_LEVEL_TRACE,
long timeout = 3000);
69 static void setLogger(logFnc logger,
int level);
70 static bool shutdown();
71 static bool connect(std::string host,
int port, uint32_t &handle,
void* data, std::string &result);
72 static bool connect(std::string url, uint32_t &handle,
void* data, std::string &result);
73 static bool connect(Poco::Net::SocketAddress sa, uint32_t &handle,
void* data, std::string &result);
74 static bool disconnect(uint32_t handle, std::string &result);
75 static bool callMethod(uint32_t handle, std::string name, std::vector<NymphType*> &values,
76 NymphType* &returnvalue, std::string &result);
77 static bool callMethodId(uint32_t handle, uint32_t
id, std::vector<NymphType*> &values,
NymphType* &returnvalue, std::string &result);
78 static bool removeMethod(uint32_t handle, std::string name);
80 static bool registerCallback(std::string name, NymphCallbackMethod method,
void* data);
81 static bool removeCallback(std::string name);
Definition: nymph_method.h:39
Definition: remote_server.h:59
Definition: remote_server.h:31
Definition: nymph_types.h:85