tests
This commit is contained in:
parent
39783bccb4
commit
7c74004488
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.cproject
|
||||
.project
|
||||
Debug
|
||||
Release
|
31
main.cpp
31
main.cpp
@ -29,12 +29,37 @@
|
||||
using namespace metacall;
|
||||
|
||||
|
||||
//
|
||||
// Serialization
|
||||
//
|
||||
|
||||
namespace metacall {
|
||||
|
||||
|
||||
bool serialize(Serializer* serializer, const char str[]) {
|
||||
serializer->writeRaw(str, strlen(str) + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool deserialize(Deserializer* deserializer, const char ** str) {
|
||||
*str = reinterpret_cast<const char*>(deserializer->readRaw(1));
|
||||
if (*str == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return deserializer->readRaw(strlen(*str)) != NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
||||
static void serverTest1(int value) {
|
||||
printf("Server function %d\n", value);
|
||||
static void serverTest1(const char str[], int num) {
|
||||
printf("Server function params are \"%s\" and \"%d\"\n", str, num);
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +85,7 @@ int main(int argc, char *argv[]) {
|
||||
server.binding()->bind(FPARAM(serverTest1));
|
||||
|
||||
do {
|
||||
client.protocol()->invoke("serverTest1", 1234);
|
||||
client.protocol()->invoke("serverTest1", "OneTwoThreeFour", 1234);
|
||||
server.advance();
|
||||
client.advance();
|
||||
}
|
||||
|
@ -77,6 +77,10 @@ void Protocol::setRate(int rate) {
|
||||
rate_ = rate;
|
||||
}
|
||||
|
||||
bool Protocol::pendingTasks() const {
|
||||
return taskMap_.size() > 0;
|
||||
}
|
||||
|
||||
bool Protocol::setHandler(TaskId id, HandlerProc handler, void* userPtr) {
|
||||
const TaskMap::iterator iter = taskMap_.find(id);
|
||||
if (iter == taskMap_.end() || iter->second.state != TASK_STATE_PENDING) {
|
||||
@ -100,11 +104,6 @@ void Protocol::clearHandlers() {
|
||||
}
|
||||
}
|
||||
|
||||
Protocol::TaskState Protocol::queryState(TaskId id) const {
|
||||
const TaskMap::const_iterator iter = taskMap_.find(id);
|
||||
return iter == taskMap_.end() ? TASK_STATE_UNDEFINED : iter->second.state;
|
||||
}
|
||||
|
||||
Stream::State Protocol::advanceStream() {
|
||||
stream_->advance();
|
||||
|
||||
|
@ -55,15 +55,15 @@ public:
|
||||
Protocol(Stream* stream, Binding* binding);
|
||||
|
||||
void advance ();
|
||||
|
||||
void setRate (int rate);
|
||||
bool setHandler (TaskId id, HandlerProc handler, void* userPtr = NULL);
|
||||
void clearHandler (TaskId id);
|
||||
void clearHandlers ();
|
||||
|
||||
template <typename R>
|
||||
TaskState queryResult (TaskId id, R* result);
|
||||
TaskState queryState (TaskId id) const;
|
||||
bool pendingTasks () const;
|
||||
|
||||
bool setHandler (TaskId id, HandlerProc handler, void* userPtr = NULL);
|
||||
void clearHandler (TaskId id);
|
||||
void clearHandlers ();
|
||||
|
||||
TaskId invoke (const Token& token);
|
||||
template <typename P1>
|
||||
|
Loading…
Reference in New Issue
Block a user