????????????????????????????????????????????????????????????????????????????????????.??EC?м??????????????????????AppModel??????????????????????????????????????????????????:
public class AppModel : EC.IAppModel
{
public void Init(EC.IApplication application)
{
application.Disconnected += (o?? e) =>
{
Beetle.Express.IChannel channel = e.Session.Channel;
Chat.Signout msg = new Signout();
msg.Name = channel.Name;
msg.From = channel.EndPoint.ToString();
foreach (Beetle.Express.IChannel other in application.Server.GetOnlines())
{
if (other != channel)
application.Server.Send(msg?? other);
}
};
}
public string Name
{
get { return "AppModel"; }
}
public string Command(string cmd)
{
throw new NotImplementedException();
}
}
????EC?????IAppModel??????幦??????AppModel??????????????????????????????;???????????????????.
?????????
????EC???????????Client?????????????????????????????????????????????????????????.
EC.ProtoClient mClient = new EC.ProtoClient("127.0.0.1");
mClient.Receive = (o?? p) => {
if (p.Message is Say)
{
Invoke(new Action<Say>(OnSay)?? p.Message);
}
else if (p.Message is Login)
{
Invoke(new Action<Login>(OnLogin)?? p.Message);
}
else if (p.Message is Signout)
{
Invoke(new Action<Signout>(OnSignout)?? p.Message);
}
};
mClient.Send(new Say{ Content=t"???"});
??????????Xamarin???????????????????????????????????????android??ios??
private IServiceChannel mClient = new ServiceChannel("10.0.2.2"??10034);
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
ServiceChannel.Register (typeof(MainActivity).Assembly);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
EditText name = FindViewById<EditText> (Resource.Id.txtname);
EditText say = FindViewById<EditText> (Resource.Id.txtsay);
TextView content = FindViewById<TextView> (Resource.Id.txtContent);
mClient.Receive = (o?? p) => {
content.Post(delegate {
content.Append(p.Message.ToString());
});
};
FindViewById<Button> (Resource.Id.btnlogin).Click += delegate {
Login login = new Login();
login.Name = name.Text;
mClient.Send(login);
};
FindViewById<Button> (Resource.Id.btnsay).Click += delegate {
Say s = new Say{ Content=say.Text};
mClient.Send(s);
};
// Get our button from the layout resource??
// and attach an event to it
}
???????????????????????????????