コード例 #1
0
ファイル: Socket.cs プロジェクト: restrepo/manos
 Socket(IOLoop loop, System.Net.Sockets.Socket socket)
     : this(loop)
 {
     this.socket = socket;
     this.address = ((IPEndPoint) socket.RemoteEndPoint).Address.ToString ();
     this.port = ((IPEndPoint) socket.RemoteEndPoint).Port;
 }
コード例 #2
0
        public static void Start(ManosApp application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            app = application;

            app.StartInternal();

            started = true;

            foreach (var ep in listenEndPoints)
            {
                var server = new HttpServer(HandleTransaction, IOLoop.CreateSocketStream());
                server.Listen(ep.Address.ToString(), ep.Port);

                servers.Add(server);
            }
            foreach (var ep in secureListenEndPoints.Keys)
            {
                var keypair = secureListenEndPoints [ep];
                var socket  = IOLoop.CreateSecureSocket(keypair.Item1, keypair.Item2);
                var server  = new HttpServer(HandleTransaction, socket);
                server.Listen(ep.Address.ToString(), ep.Port);

                servers.Add(server);
            }

            ioloop.Start();
        }
コード例 #3
0
 public HttpServer(IOLoop loop, HttpConnectionCallback callback, Socket socket, bool closeOnEnd = false)
 {
     this.callback   = callback;
     this.socket     = socket;
     this.closeOnEnd = closeOnEnd;
     this.IOLoop     = loop;
 }
コード例 #4
0
        public UdpReceiver(IOLoop loop, int maxMessageSize)
        {
            this.loop = loop;

            readBuffer          = new byte[maxMessageSize];
            this.maxMessageSize = maxMessageSize;
        }
コード例 #5
0
ファイル: Timers.cs プロジェクト: waqashaneef/Node.cs
        public Timers(Manos.IO.IOLoop loop, int initialSize = 2)
        {
            this.loop = loop;
            freeList  = new Queue <int>(initialSize);

            growWatchers(initialSize);
        }
コード例 #6
0
ファイル: Socket.cs プロジェクト: aaronfeng/manos
 public SocketStream(IOLoop loop, Socket sock)
     : this(loop)
 {
     socket = sock;
     StartTimeout();
     address = ((IPEndPoint)socket.RemoteEndPoint).Address.ToString();
     port = ((IPEndPoint)socket.RemoteEndPoint).Port;
 }
コード例 #7
0
        public Boundary(IOLoop loop, int maxWorkPerLoop)
        {
            asyncWatcher = new AsyncWatcher((LibEvLoop)loop.EventLoop, (l, w, et) => ProcessWork());
            asyncWatcher.Start();

            workQueue           = new ConcurrentQueue <Action> ();
            this.maxWorkPerLoop = maxWorkPerLoop;
        }
コード例 #8
0
        public Boundary(IOLoop loop, int maxWorkPerLoop)
        {
            asyncWatcher = loop.NewAsyncWatcher(ProcessWork);
            asyncWatcher.Start();

            workQueue           = new ConcurrentQueue <Action> ();
            this.maxWorkPerLoop = maxWorkPerLoop;
        }
コード例 #9
0
ファイル: RunCommand.cs プロジェクト: txdv/manos
        public int Run(string app, IList <string> args)
        {
            IManosRun mr = Loader.LoadLibrary <IManosRun> (app, new List <string> ());

            IOLoop loop = IOLoop.Instance;

            string [] strargs = new string [args.Count];
            for (int i = 0; i < strargs.Length; i++)
            {
                strargs [i] = args [i];
            }

            if (mr == null)
            {
                Console.WriteLine("Binary {0} has no suitable entry point", app);
                return(-1);
            }

            int ret = mr.Main(strargs);

            loop.Start();

            return(ret);
        }
コード例 #10
0
ファイル: Socket.cs プロジェクト: restrepo/manos
 public Socket(IOLoop loop)
 {
     if (loop == null)
         throw new ArgumentNullException ("loop");
     this.loop = loop;
 }
コード例 #11
0
 public Boundary(IOLoop loop) : this(loop, 18)
 {
 }
コード例 #12
0
 public Complete(IOLoop loop)
 {
     Preconditions.IsNotNull(loop, "IOLoop has not been defined - can't set a timeout");
     this.loop = loop;
 }
コード例 #13
0
 public UdpReceiver(IOLoop loop) : this(loop, 128 * 1024)
 {
 }
コード例 #14
0
ファイル: Program.cs プロジェクト: waqashaneef/Node.cs
        public static int Main(string[] args)
        {
            GlobalErrorHandler.Instance.SetGlobalErrorHandler((o, e) =>
            {
                Console.WriteLine(e.ExceptionObject);
                IOLoop.Instance.Stop();
                Environment.Exit(-1);
            });

            if (args.Length == 0)
            {
                Console.Error.WriteLine("node yourdll.dll [args[]]");
                return(-1);
            }

            string dll = args[0];

            if (!dll.EndsWith(".dll"))
            {
                dll += ".dll";
            }

            if (!File.Exists(dll))
            {
                Console.Error.WriteLine("dll '{0}' not found", dll);
                return(-1);
            }

            Assembly asy;

            try
            {
                asy = Assembly.LoadFile(args[0]);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("failed to load dll '{0}'. Exception was {1}", dll, ex.Message);
                return(-1);
            }

            Type[] types = asy.GetTypes();

            INodeProgram program = null;

            foreach (var type in types)
            {
                if (typeof(INodeProgram).IsAssignableFrom(type))
                {
                    try
                    {
                        program = (INodeProgram)asy.CreateInstance(type.FullName);

                        break;
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine("failed to type '{0}'. Exception was {1}", type.FullName, ex.Message);
                        return(-1);
                    }
                }
            }

            if (program == null)
            {
                Console.Error.WriteLine("Assembly '{0}' doesn't appear to have a INodeProgram type", asy.FullName);
                return(-1);
            }

            string[] progArgs = new string[args.Length - 1];

            for (int i = 1; i < args.Length; i++)
            {
                progArgs[i] = args[i];
            }

            IOLoop loop = IOLoop.Instance;

            int retCode = 0;

            Manos.Timeout t = new Manos.Timeout(TimeSpan.FromSeconds(1), RepeatBehavior.Single, null,
                                                (a, o) =>
            {
                Console.WriteLine("Starting program");

                try
                {
                    retCode = program.Main(progArgs);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("NodeProgram failed on startup {0}", ex);

                    loop.Stop();
                    retCode = -1;
                }

                if (retCode != 0)
                {
                    loop.Stop();
                }
            });

            loop.AddTimeout(t);

            loop.Start();

            return(retCode);
        }
コード例 #15
0
 public HttpServer(IOLoop ioloop, bool closeOnEnd = false)
 {
     this.ioloop     = ioloop;
     this.closeOnEnd = closeOnEnd;
 }
コード例 #16
0
ファイル: IOLoop.cs プロジェクト: aaronfeng/manos
 public ManagedLoop(IOLoop owner)
 {
     this.owner = owner;
 }
コード例 #17
0
ファイル: Socket.cs プロジェクト: aaronfeng/manos
 public SocketStream(IOLoop loop)
 {
     this.loop = loop;
 }
コード例 #18
0
 public HttpServer(HttpConnectionCallback callback, IOLoop ioloop, bool closeOnEnd = false)
 {
     this.callback   = callback;
     this.ioloop     = ioloop;
     this.closeOnEnd = closeOnEnd;
 }
コード例 #19
0
 public HttpServer(HttpConnectionCallback callback, IOLoop ioloop)
 {
     this.callback = callback;
     this.ioloop   = ioloop;
 }