summaryrefslogtreecommitdiff
path: root/Ivy/IvyProbe/IvyProbe.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy/IvyProbe/IvyProbe.cs')
-rw-r--r--Ivy/IvyProbe/IvyProbe.cs166
1 files changed, 166 insertions, 0 deletions
diff --git a/Ivy/IvyProbe/IvyProbe.cs b/Ivy/IvyProbe/IvyProbe.cs
new file mode 100644
index 0000000..31c024a
--- /dev/null
+++ b/Ivy/IvyProbe/IvyProbe.cs
@@ -0,0 +1,166 @@
+namespace IvyProbe
+{
+ using System;
+ using System.Windows.Forms;
+ using IvyBus;
+ using System.IO;
+ using System.Runtime.Serialization;
+ using System.Runtime.Serialization.Formatters.Binary;
+ using System.Reflection;
+ using System.Net;
+
+ partial class IvyProbe : System.Windows.Forms.Form
+ {
+
+ public IvyProbe()
+ {
+ //
+ // Requis pour la prise en charge du Concepteur Windows Forms
+ //
+ InitializeComponent();
+ }
+
+ private void append(string s)
+ {
+ // je mettrais bien la date, aussi.
+ ta.AppendText(s + "\r\n");
+ }
+
+ private void connect(object sender, IvyEventArgs e)
+ {
+ append(e.Client.ApplicationName + " connected from " + Dns.GetHostEntry(e.Client.RemoteAddress).HostName);
+ }
+ private void disconnect(object sender, IvyEventArgs e)
+ {
+ append(e.Client.ApplicationName + " disconnected from " + Dns.GetHostEntry(e.Client.RemoteAddress).HostName);
+ }
+ private void die(object sender, IvyDieEventArgs e)
+ {
+ append("receive die from " + e.Client.ApplicationName + " cause: " + e.Argument);
+ }
+ private void directMessage(object sender, IvyEventArgs e)
+ {
+ append(e.Client.ApplicationName + " direct Message " + e.Id + e.Argument);
+ }
+ private void receive(object sender, IvyMessageEventArgs e)
+ {
+ string receive_str = "client " + e.Client.ApplicationName + " envoie: [";
+ receive_str += string.Join(",", e.Arguments);
+ receive_str += "]";
+ receive_str += " for '" + ((IvyApplicationBinding)sender).FormatedExpression + "'";
+ append(receive_str);
+ }
+ public void RegexpCB(System.Object event_sender, System.EventArgs e)
+ {
+ // ajoute la nouvelle regex
+ string regexp = tbRegexp.Text;
+ regexp.Trim();
+ int regexp_id = bus.BindMsg(regexp, receive);
+ tbRegexp.Text = "";
+ append( "bind("+regexp_id+") ->"+regexp);
+ }
+ 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, receive);
+ tbRegexp.Text = "";
+ append( "bind("+regexp_id+") ->"+expression);
+ }
+
+
+ public void SendCB(System.Object event_sender, System.EventArgs e)
+ {
+ int count;
+ System.String tosend = tbMsg.Text;
+ tbMsg.Text = "";
+ DateTime debut = DateTime.Now;
+ count = bus.SendMsg(tosend);
+ TimeSpan duree = DateTime.Now - debut;
+ append("Sending '" + tosend + "' count " + count + " in " + duree.TotalMilliseconds + " ms");
+ }
+
+ [STAThread]
+ public static void Main(System.String[] args)
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new IvyProbe());
+
+ }
+
+ private void tbMsg_TextChanged(object sender, System.EventArgs e)
+ {
+ btSend.Enabled = (tbMsg.Text != "");
+ }
+
+ private void tbRegexp_TextChanged(object sender, System.EventArgs e)
+ {
+ 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(object sender, IvyEventArgs e)
+ {
+ append(e.Client.ApplicationName + " add binding '" + e.Argument + "'");
+ }
+
+ private void bus_removeBinding(object sender, IvyEventArgs e)
+ {
+ append(e.Client.ApplicationName + " remove binding '" + e.Argument + "'");
+ }
+
+ private void bus_BindingFilter(object sender, IvyEventArgs e)
+ {
+ // should not appen in this application because no messages classes declared
+ append(e.Client.ApplicationName + " filter binding '" + e.Argument + "'");
+ }
+ private void bus_ErrorMessage(object sender, IvyEventArgs e)
+ {
+ append(e.Client.ApplicationName + " error message " + e.Id + " '" + e.Argument + "'");
+ }
+
+ private void busDomain_DomainChanged(object sender, EventArgs e)
+ {
+ bus.Stop();
+ bus.Start(busDomain.Domain);
+ }
+
+ private void IvyProbe_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ bus.Stop();
+ }
+
+ private void IvyProbe_Load(object sender, EventArgs e)
+ {
+ bus.Start(busDomain.Domain);
+ }
+
+ private void ivyprobe(object sender, IvyMessageEventArgs e)
+ {
+ // just for testing of Desin Bindings
+ receive(sender, e);
+ }
+
+
+ }
+} \ No newline at end of file