summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyProbe/IvyProbe.cs
diff options
context:
space:
mode:
authorfcolin2007-02-01 10:05:59 +0000
committerfcolin2007-02-01 10:05:59 +0000
commit736a29430c5566e4e6dd786aee62540c13e6583d (patch)
tree677f2b2b0cfc1691f9197a9ef116f1f0cee6e0bf /CSharp/Ivy/IvyProbe/IvyProbe.cs
parent131ee43a6e752d53c2dfda9a0fc13aeccb0b7a6c (diff)
downloadivy-csharp-736a29430c5566e4e6dd786aee62540c13e6583d.zip
ivy-csharp-736a29430c5566e4e6dd786aee62540c13e6583d.tar.gz
ivy-csharp-736a29430c5566e4e6dd786aee62540c13e6583d.tar.bz2
ivy-csharp-736a29430c5566e4e6dd786aee62540c13e6583d.tar.xz
Utilisateur : Fcolin Date : 30/11/05 Heure : 10:27 Archivé dans $/CSharp/Ivy/IvyTest Commentaire: (vss 5)
Diffstat (limited to 'CSharp/Ivy/IvyProbe/IvyProbe.cs')
-rw-r--r--CSharp/Ivy/IvyProbe/IvyProbe.cs135
1 files changed, 97 insertions, 38 deletions
diff --git a/CSharp/Ivy/IvyProbe/IvyProbe.cs b/CSharp/Ivy/IvyProbe/IvyProbe.cs
index 9e4e34b..f98ece6 100644
--- a/CSharp/Ivy/IvyProbe/IvyProbe.cs
+++ b/CSharp/Ivy/IvyProbe/IvyProbe.cs
@@ -20,8 +20,8 @@ namespace IvyTest
private System.ComponentModel.Container components = null;
internal Ivy bus;
- internal String regexp;
- internal int regexp_id;
+ private System.Windows.Forms.Button btBindSimple;
+ private System.Windows.Forms.Button btUnbind;
public IvyTest()
{
//
@@ -29,15 +29,15 @@ namespace IvyTest
//
InitializeComponent();
- regexp = "";
- bus = new Ivy("C# TESTBUS", "Testbus ridi",this);
+ bus = new Ivy("C# TESTBUS", "Testbus ready",this);
bus.Debug = true;
bus.clientConnected += new Ivy.ClientConnectedHandler( connect );
bus.clientDisconnected += new Ivy.ClientDisconnectedHandler( disconnect );
+ bus.addBinding +=new IvyBus.Ivy.ClientAddBindingHandler(bus_addBinding);
+ bus.removeBinding +=new IvyBus.Ivy.ClientAddBindingHandler(bus_removeBinding);
bus.dieReceived += new Ivy.DieHandler( die );
bus.directMessageReceived += new Ivy.DirectMessageHandler( directMessage );
bus.start(null);
- regexp_id = -1;
}
/// <summary>
@@ -71,15 +71,17 @@ namespace IvyTest
this.ta = new System.Windows.Forms.TextBox();
this.btBind = new System.Windows.Forms.Button();
this.btSend = new System.Windows.Forms.Button();
+ this.btUnbind = new System.Windows.Forms.Button();
+ this.btBindSimple = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(40, 16);
+ this.label1.Size = new System.Drawing.Size(24, 16);
this.label1.TabIndex = 0;
- this.label1.Text = "Regexp:";
+ this.label1.Text = "exp:";
//
// label2
//
@@ -93,9 +95,9 @@ namespace IvyTest
//
this.tbRegexp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.tbRegexp.Location = new System.Drawing.Point(64, 0);
+ this.tbRegexp.Location = new System.Drawing.Point(32, 0);
this.tbRegexp.Name = "tbRegexp";
- this.tbRegexp.Size = new System.Drawing.Size(224, 20);
+ this.tbRegexp.Size = new System.Drawing.Size(216, 20);
this.tbRegexp.TabIndex = 2;
this.tbRegexp.Text = "(.*)";
this.tbRegexp.TextChanged += new System.EventHandler(this.tbRegexp_TextChanged);
@@ -106,7 +108,7 @@ namespace IvyTest
| System.Windows.Forms.AnchorStyles.Right)));
this.tbMsg.Location = new System.Drawing.Point(72, 240);
this.tbMsg.Name = "tbMsg";
- this.tbMsg.Size = new System.Drawing.Size(216, 20);
+ this.tbMsg.Size = new System.Drawing.Size(232, 20);
this.tbMsg.TabIndex = 3;
this.tbMsg.Text = "msg";
this.tbMsg.TextChanged += new System.EventHandler(this.tbMsg_TextChanged);
@@ -119,34 +121,57 @@ namespace IvyTest
this.ta.Location = new System.Drawing.Point(0, 32);
this.ta.Multiline = true;
this.ta.Name = "ta";
- this.ta.Size = new System.Drawing.Size(368, 200);
+ this.ta.Size = new System.Drawing.Size(384, 200);
this.ta.TabIndex = 4;
this.ta.Text = "";
//
// btBind
//
this.btBind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btBind.Location = new System.Drawing.Point(296, 0);
+ this.btBind.Location = new System.Drawing.Point(248, 0);
this.btBind.Name = "btBind";
- this.btBind.Size = new System.Drawing.Size(64, 24);
+ this.btBind.Size = new System.Drawing.Size(40, 32);
this.btBind.TabIndex = 5;
- this.btBind.Text = "bind";
+ this.btBind.Text = "bind regexp";
this.btBind.Click += new System.EventHandler(this.RegexpCB);
//
// btSend
//
this.btSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.btSend.Location = new System.Drawing.Point(296, 240);
+ this.btSend.Location = new System.Drawing.Point(312, 240);
this.btSend.Name = "btSend";
this.btSend.Size = new System.Drawing.Size(64, 24);
this.btSend.TabIndex = 6;
this.btSend.Text = "Send";
this.btSend.Click += new System.EventHandler(this.SendCB);
//
+ // btUnbind
+ //
+ this.btUnbind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btUnbind.Location = new System.Drawing.Point(336, 0);
+ this.btUnbind.Name = "btUnbind";
+ this.btUnbind.Size = new System.Drawing.Size(48, 24);
+ this.btUnbind.TabIndex = 7;
+ this.btUnbind.Text = "unbind";
+ this.btUnbind.Click += new System.EventHandler(this.btUnbind_Click);
+ //
+ // btBindSimple
+ //
+ this.btBindSimple.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btBindSimple.Location = new System.Drawing.Point(288, 0);
+ this.btBindSimple.Name = "btBindSimple";
+ this.btBindSimple.Size = new System.Drawing.Size(40, 32);
+ this.btBindSimple.TabIndex = 8;
+ this.btBindSimple.Text = "bind simple";
+ this.btBindSimple.Click += new System.EventHandler(this.ExpressionCB);
+ //
// IvyTest
//
+ this.AcceptButton = this.btSend;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(368, 266);
+ this.ClientSize = new System.Drawing.Size(384, 266);
+ this.Controls.Add(this.btBindSimple);
+ this.Controls.Add(this.btUnbind);
this.Controls.Add(this.btSend);
this.Controls.Add(this.btBind);
this.Controls.Add(this.ta);
@@ -182,30 +207,39 @@ namespace IvyTest
// return true terminate the application
return false;
}
- private void directMessage(IvyClient client, int id, System.String arg)
+ private void directMessage(IvyClient client, int id, byte[] arg)
{
append(client.ApplicationName + " direct Message " + id + arg);
}
public void RegexpCB(System.Object event_sender, System.EventArgs e)
{
- // enlever l'ancienne regex
- if ( regexp_id >=0 )
- bus.unBindMsg(regexp_id);
// ajoute la nouvelle regex
- regexp = tbRegexp.Text;
+ string regexp = tbRegexp.Text;
regexp.Trim();
- regexp_id = bus.bindMsg(regexp, new Ivy.MessageHandler(receive));
+ int regexp_id = bus.bindMsg(regexp, new Ivy.MessageHandler(receive));
tbRegexp.Text = "";
append( "bind("+regexp_id+") ->"+regexp);
}
- private void receive(IvyClient client, String[] args)
+ public void ExpressionCB(System.Object event_sender, System.EventArgs e)
+ {
+ // ajoute la nouvelle regex
+ string expression = tbRegexp.Text;
+ expression.Trim();
+ int regexp_id = bus.bindSimpleMsg(expression, new Ivy.MessageHandler(receive));
+ tbRegexp.Text = "";
+ append( "bind("+regexp_id+") ->"+expression);
+ }
+ private void receive(IvyClient client, IvyArgument args)
{
- String out_Renamed = "client " + client.ApplicationName + " envoie: [ ";
- for (int i = 0; i < args.Length; i++)
- out_Renamed = out_Renamed + args[i] + ((i < args.Length - 1)?" , ":"");
- out_Renamed = out_Renamed + " ]";
- append(out_Renamed);
+ string receive_str = "client " + client.ApplicationName + " envoie: [";
+ for (int i = 0; i < args.Length; i++)
+ {
+ receive_str += args[i].Value+ ",";
+ }
+ receive_str = receive_str.TrimEnd(new char[] { ',' });
+ receive_str += "]";
+ append(receive_str);
}
private void append(System.String s)
{
@@ -215,12 +249,11 @@ namespace IvyTest
public void SendCB(System.Object event_sender, System.EventArgs e)
{
- int count;
- System.String tosend = tbMsg.Text;
- tbMsg.Text = "";
- count = bus.sendMsg(tosend);
- append("Sending '" + tosend + "' count " + count);
-
+ int count;
+ System.String tosend = tbMsg.Text;
+ tbMsg.Text = "";
+ count = bus.sendMsg(tosend);
+ append("Sending '" + tosend + "' count " + count);
}
[STAThread]
@@ -238,10 +271,36 @@ namespace IvyTest
private void tbRegexp_TextChanged(object sender, System.EventArgs e)
{
- btBind.Enabled = (tbRegexp.Text != "");
+ bool enable = (tbRegexp.Text != "");
+ btBind.Enabled = enable;
+ btBindSimple.Enabled = enable;
+ btUnbind.Enabled = enable;
+ }
+
+ private void btUnbind_Click(object sender, System.EventArgs e)
+ {
+ // enleve la regex
+ string regexp = tbRegexp.Text;
+ bool removed = bus.unBindMsg( regexp );
+ if ( removed )
+ {
+ append( "unbind("+regexp+")");
+ tbRegexp.Text = "";
+ }
+ else
+ {
+ append( "unbind can't find binding ("+regexp+")");
+ }
+ }
+
+ private void bus_addBinding(IvyClient app, string arg)
+ {
+ append( app.ApplicationName + " add binding '"+arg+"'");
+ }
+
+ private void bus_removeBinding(IvyClient app, string arg)
+ {
+ append( app.ApplicationName + " remove binding '"+arg+"'");
}
-
}
-
- // EOF
} \ No newline at end of file