-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.cs
56 lines (51 loc) · 1.41 KB
/
Form1.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using aktos_dcs_cs;
namespace gui_example
{
/**
run aktos-dcs/examples/ponger.py in order to communicate with another actor
**/
public partial class Form1 : Form
{
ExamplePinger dcs = new ExamplePinger();
public Form1()
{
InitializeComponent();
dcs.event_PingMessage += handle_PingMessage;
}
private void handle_PingMessage(Dictionary<string, object> msg)
{
string received_text = (string)msg["text"];
if (label1.InvokeRequired)
{
label1.Invoke(new MethodInvoker(delegate { label1.Text = received_text; }));
}
// do any other work here
}
private void button1_Click(object sender, EventArgs e)
{
dcs.send_PongMessage(textBox1.Text);
}
}
class ExamplePinger : Actor
{
public event msg_callback event_PingMessage;
public void send_PongMessage(string msg_json)
{
string msg_ser = string.Format(@"
{{""PongMessage"":
{{""text"": ""{0}""}}
}}
", msg_json);
send(msg_ser);
}
}
}