1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
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.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)
{
}
}
}
|