Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Burton2012-05-01 14:44:08 -0400
committerFelix Burton2012-05-01 14:44:08 -0400
commit742370f8aa3cbec12b2df414513acc30aa765634 (patch)
treee78a95f98d49fd3a88160daf03fee1a8a9b22cb6
parent6a6b305b0b0d882b76cd7a33e8dd5f2f96c66257 (diff)
downloadorg.eclipse.tcf.agent-742370f8aa3cbec12b2df414513acc30aa765634.tar.gz
org.eclipse.tcf.agent-742370f8aa3cbec12b2df414513acc30aa765634.tar.xz
org.eclipse.tcf.agent-742370f8aa3cbec12b2df414513acc30aa765634.zip
TCF Agent: Add send_redirect_command_by_props() to be able to redirect to a peer that is not know by the remote Locator
For consistency also changed the name of send_redirect_command() to send_redirect_command_by_id(). For backwards compatibility a #define is used to map send_redirect_command() to send_redirect_command_by_id().
-rw-r--r--agent/tcf/framework/protocol.c27
-rw-r--r--agent/tcf/framework/protocol.h6
2 files changed, 31 insertions, 2 deletions
diff --git a/agent/tcf/framework/protocol.c b/agent/tcf/framework/protocol.c
index fcf896b2..9574f408 100644
--- a/agent/tcf/framework/protocol.c
+++ b/agent/tcf/framework/protocol.c
@@ -476,7 +476,7 @@ static void redirect_done(Channel * c, void * client_data, int error) {
info->handler(c, info->client_data, error);
}
-ReplyHandlerInfo * send_redirect_command(Channel * c, const char * peerId, ReplyHandlerCB handler, void * client_data) {
+ReplyHandlerInfo * send_redirect_command_by_id(Channel * c, const char * peerId, ReplyHandlerCB handler, void * client_data) {
struct sendRedirectInfo * info = (struct sendRedirectInfo *)loc_alloc_zero(sizeof *info);
ReplyHandlerInfo * rh;
@@ -491,6 +491,31 @@ ReplyHandlerInfo * send_redirect_command(Channel * c, const char * peerId, Reply
return rh;
}
+ReplyHandlerInfo * send_redirect_command_by_props(Channel * c, const PeerServer * ps, ReplyHandlerCB handler, void * client_data) {
+ struct sendRedirectInfo * info = (struct sendRedirectInfo *)loc_alloc_zero(sizeof *info);
+ ReplyHandlerInfo * rh;
+ unsigned i;
+
+ assert(c->state == ChannelStateConnected);
+ c->state = ChannelStateRedirectSent;
+ info->handler = handler;
+ info->client_data = client_data;
+ rh = protocol_send_command(c, LOCATOR, "redirect", redirect_done, info);
+ write_stream(&c->out, '{');
+ for (i = 0; i < ps->ind; i++) {
+ if (i > 0) {
+ write_stream(&c->out, ',');
+ }
+ json_write_string(&c->out, ps->list[i].name);
+ write_stream(&c->out, ':');
+ json_write_string(&c->out, ps->list[i].value);
+ }
+ write_stream(&c->out, '}');
+ write_stream(&c->out, 0);
+ write_stream(&c->out, MARKER_EOM);
+ return rh;
+}
+
static void connect_done(Channel * c) {
assert(c->state == ChannelStateConnected);
notify_channel_opened(c);
diff --git a/agent/tcf/framework/protocol.h b/agent/tcf/framework/protocol.h
index c7d886fd..aa2ca7d7 100644
--- a/agent/tcf/framework/protocol.h
+++ b/agent/tcf/framework/protocol.h
@@ -112,7 +112,11 @@ extern int protocol_cancel_command(ReplyHandlerInfo * rh);
/*
* Send redirect command.
*/
-extern ReplyHandlerInfo * send_redirect_command(Channel * c, const char * peerId, ReplyHandlerCB handler, void * client_data);
+extern ReplyHandlerInfo * send_redirect_command_by_id(Channel * c, const char * peerId, ReplyHandlerCB handler, void * client_data);
+extern ReplyHandlerInfo * send_redirect_command_by_props(Channel * c, const PeerServer * ps, ReplyHandlerCB handler, void * client_data);
+
+/* Deprecated, use send_redirect_by_id_command */
+#define send_redirect_command send_redirect_command_by_id
/*
* Create protocol instance

Back to the top