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 receive(object sender, IvyMessageEventArgs e) { string receive_str = "client " + e.Client.ApplicationName + " envoie: ["; // Copy the collection to a new array starting at index 0. String[] args = new String[e.Arguments.Count]; e.Arguments.CopyTo(args, 0); receive_str += string.Join(",", args); receive_str += "]"; append(receive_str); } private void directMessage(object sender, IvyEventArgs e) { append(e.Client.ApplicationName + " direct Message " + e.Id + e.Argument); } 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); } [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) { } } }