Example #1
0
 void Write(IRpcMail mail, string name, string type, object[] args)
 {
     var str = string.Format(DateTime.Now + " " +  name + "[" + type + "] " + args.ToDelimitedString());
     Console.WriteLine(str);
     lock(writer)
         writer.WriteLine(str);
 }
Example #2
0
        public void Call(IRpcMail mail)
        {
            var func = GetFunction(mail);
            if (func == null) return;

            var args = ConvertParams(mail, func.Item2);
            func.Item2.Call(func.Item1, args);
        }
Example #3
0
 private Tuple<object, MethodInfo> GetFunction(IRpcMail mail)
 {
     Tuple<object, MethodInfo> func;
     if (!functions.TryGetValue(mail.Message.Name, out func) ||
                     mail.Message.Args.Length != func.Item2.GetParameters().Length - 1)
         return null;
     return func;
 }
Example #4
0
 private static object[] ConvertParams(IRpcMail mail, MethodInfo func)
 {
     var p = func.Parameters();
     var args = new object[p.Count];
     args[0] = mail;
     for (int i = 0; i < mail.Message.Args.Length; i++)
         args[i + 1] = ConvertEx.Convert(mail.Message.Args[i], p[i + 1].ParameterType);
     return args;
 }
Example #5
0
 void GetProcesses(IRpcMail mail)
 {
     log.Info("GetProcesses " + mail.From);
     var actors = Node.World.Actors
             .Select(n=> new ActorInfo{
                     Id = n.Id,
                     IsAlive = n.IsAlive,
                 })
             .OrderBy(n=>n.IsAlive)
             .ThenBy(n=>n.Id)
             .ToArray();
     Node.Reply(mail, new[]{actors});
 }
Example #6
0
 void GetConnections(IRpcMail mail)
 {
     log.Info("GetConnections " + mail.From);
     var conn = Node.Router.Connections.ToArray(n=>n.ToString());
     Node.Reply(mail, new[]{conn});
 }
Example #7
0
 void Subscribe(IRpcMail mail, Expression<Func<IRpcMail, bool>> subscribe)
 {
 }
Example #8
0
 protected override void HandleMessage(IRpcMail mail)
 {
     base.HandleMessage (mail);
 }