Ejemplo n.º 1
0
        static public RemoteAction Send(OverlayHost myHost, OverlayEndpoint remoteHost, Node.DisconnectProcessor dp,
                                        MessageType mt, params object[] args)
        {
            RemoteAction ra = new RemoteAction();

            ra.remoteHost = remoteHost;

            bool assigned = false;

            for (int i = 0; i < args.Length; ++i)
            {
                if (args[i].GetType() == typeof(RemoteActionIdInject))
                {
                    args[i]  = ra.Id;       // id is injected at first RemoteActionIdInject argument
                    assigned = true;
                    break;
                }
            }

            if (!assigned)
            {
                List <object> lst = new List <object>();
                lst.Add(ra.Id);             // or in front if there isn't one
                lst.AddRange(args);
                args = lst.ToArray();
            }

            if (dp != null)
            {
                myHost.TryConnectAsync(remoteHost, dp);
            }
            myHost.SendMessage(remoteHost, mt, args);

            return(ra);
        }
Ejemplo n.º 2
0
 public static void SendMessage(this OverlayHost host, OverlayEndpoint remote, MessageType mt, params object[] objs)
 {
     host.SendMessage(remote, new GameMessage(mt, objs));
 }