|
|
@ -236,7 +236,7 @@ void RemoteClient::disconnect()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool RemoteClient::bind(color_ostream &out, RemoteFunctionBase *function,
|
|
|
|
bool RemoteClient::bind(color_ostream &out, RemoteFunctionBase *function,
|
|
|
|
const std::string &name, const std::string &proto)
|
|
|
|
const std::string &name, const std::string &plugin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!active || !socket->IsSocketValid())
|
|
|
|
if (!active || !socket->IsSocketValid())
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -247,8 +247,8 @@ bool RemoteClient::bind(color_ostream &out, RemoteFunctionBase *function,
|
|
|
|
auto in = bind_call.in();
|
|
|
|
auto in = bind_call.in();
|
|
|
|
|
|
|
|
|
|
|
|
in->set_method(name);
|
|
|
|
in->set_method(name);
|
|
|
|
if (!proto.empty())
|
|
|
|
if (!plugin.empty())
|
|
|
|
in->set_plugin(proto);
|
|
|
|
in->set_plugin(plugin);
|
|
|
|
in->set_input_msg(function->p_in_template->GetTypeName());
|
|
|
|
in->set_input_msg(function->p_in_template->GetTypeName());
|
|
|
|
in->set_output_msg(function->p_out_template->GetTypeName());
|
|
|
|
in->set_output_msg(function->p_out_template->GetTypeName());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -326,23 +326,23 @@ void RPCFunctionBase::reset(bool free)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool RemoteFunctionBase::bind(color_ostream &out, RemoteClient *client,
|
|
|
|
bool RemoteFunctionBase::bind(color_ostream &out, RemoteClient *client,
|
|
|
|
const std::string &name, const std::string &proto)
|
|
|
|
const std::string &name, const std::string &plugin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isValid())
|
|
|
|
if (isValid())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (p_client == client && this->name == name && this->proto == proto)
|
|
|
|
if (p_client == client && this->name == name && this->plugin == plugin)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
out.printerr("Function already bound to %s::%s\n",
|
|
|
|
out.printerr("Function already bound to %s::%s\n",
|
|
|
|
this->proto.c_str(), this->name.c_str());
|
|
|
|
this->plugin.c_str(), this->name.c_str());
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this->name = name;
|
|
|
|
this->name = name;
|
|
|
|
this->proto = proto;
|
|
|
|
this->plugin = plugin;
|
|
|
|
this->p_client = client;
|
|
|
|
this->p_client = client;
|
|
|
|
|
|
|
|
|
|
|
|
return client->bind(out, this, name, proto);
|
|
|
|
return client->bind(out, this, name, plugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sendRemoteMessage(CSimpleSocket *socket, int16_t id, const MessageLite *msg, bool size_ready)
|
|
|
|
bool sendRemoteMessage(CSimpleSocket *socket, int16_t id, const MessageLite *msg, bool size_ready)
|
|
|
@ -371,14 +371,14 @@ command_result RemoteFunctionBase::execute(color_ostream &out,
|
|
|
|
if (!isValid())
|
|
|
|
if (!isValid())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("Calling an unbound RPC function %s::%s.\n",
|
|
|
|
out.printerr("Calling an unbound RPC function %s::%s.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str());
|
|
|
|
this->plugin.c_str(), this->name.c_str());
|
|
|
|
return CR_NOT_IMPLEMENTED;
|
|
|
|
return CR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!p_client->socket->IsSocketValid())
|
|
|
|
if (!p_client->socket->IsSocketValid())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("In call to %s::%s: invalid socket.\n",
|
|
|
|
out.printerr("In call to %s::%s: invalid socket.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str());
|
|
|
|
this->plugin.c_str(), this->name.c_str());
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -387,14 +387,14 @@ command_result RemoteFunctionBase::execute(color_ostream &out,
|
|
|
|
if (send_size > RPCMessageHeader::MAX_MESSAGE_SIZE)
|
|
|
|
if (send_size > RPCMessageHeader::MAX_MESSAGE_SIZE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("In call to %s::%s: message too large: %d.\n",
|
|
|
|
out.printerr("In call to %s::%s: message too large: %d.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str(), send_size);
|
|
|
|
this->plugin.c_str(), this->name.c_str(), send_size);
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!sendRemoteMessage(p_client->socket, id, input, true))
|
|
|
|
if (!sendRemoteMessage(p_client->socket, id, input, true))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("In call to %s::%s: I/O error in send.\n",
|
|
|
|
out.printerr("In call to %s::%s: I/O error in send.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str());
|
|
|
|
this->plugin.c_str(), this->name.c_str());
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -409,7 +409,7 @@ command_result RemoteFunctionBase::execute(color_ostream &out,
|
|
|
|
if (!readFullBuffer(p_client->socket, &header, sizeof(header)))
|
|
|
|
if (!readFullBuffer(p_client->socket, &header, sizeof(header)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("In call to %s::%s: I/O error in receive header.\n",
|
|
|
|
out.printerr("In call to %s::%s: I/O error in receive header.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str());
|
|
|
|
this->plugin.c_str(), this->name.c_str());
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -421,7 +421,7 @@ command_result RemoteFunctionBase::execute(color_ostream &out,
|
|
|
|
if (header.size < 0 || header.size > RPCMessageHeader::MAX_MESSAGE_SIZE)
|
|
|
|
if (header.size < 0 || header.size > RPCMessageHeader::MAX_MESSAGE_SIZE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("In call to %s::%s: invalid received size %d.\n",
|
|
|
|
out.printerr("In call to %s::%s: invalid received size %d.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str(), header.size);
|
|
|
|
this->plugin.c_str(), this->name.c_str(), header.size);
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -430,7 +430,7 @@ command_result RemoteFunctionBase::execute(color_ostream &out,
|
|
|
|
if (!readFullBuffer(p_client->socket, buf, header.size))
|
|
|
|
if (!readFullBuffer(p_client->socket, buf, header.size))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("In call to %s::%s: I/O error in receive %d bytes of data.\n",
|
|
|
|
out.printerr("In call to %s::%s: I/O error in receive %d bytes of data.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str(), header.size);
|
|
|
|
this->plugin.c_str(), this->name.c_str(), header.size);
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -439,7 +439,7 @@ command_result RemoteFunctionBase::execute(color_ostream &out,
|
|
|
|
if (!output->ParseFromArray(buf, header.size))
|
|
|
|
if (!output->ParseFromArray(buf, header.size))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("In call to %s::%s: error parsing received result.\n",
|
|
|
|
out.printerr("In call to %s::%s: error parsing received result.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str());
|
|
|
|
this->plugin.c_str(), this->name.c_str());
|
|
|
|
delete[] buf;
|
|
|
|
delete[] buf;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
return CR_LINK_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -453,7 +453,7 @@ command_result RemoteFunctionBase::execute(color_ostream &out,
|
|
|
|
text_decoder.decode(&text_data);
|
|
|
|
text_decoder.decode(&text_data);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
out.printerr("In call to %s::%s: received invalid text data.\n",
|
|
|
|
out.printerr("In call to %s::%s: received invalid text data.\n",
|
|
|
|
this->proto.c_str(), this->name.c_str());
|
|
|
|
this->plugin.c_str(), this->name.c_str());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|