Exemplo n.º 1
0
        public Session NewSession(HumbleServer humbleServer, TcpClient client, Framing framing, string delimiter)
        {
            var session = new Session(this, humbleServer, client, framing, delimiter);

            lock (_locker)
            {
                _sessions.Add(session);
            }

            return session;
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            //// create the server, configure echo command and start listening
            var server = new HumbleServer();
            server.AddCommand("echo", () => new EchoCommand());
            server.Start(0);

            //// create the client, connect to the server, send the command and the parameters
            var client = new HumbleClient();
            client.Connect("localhost", server.Port);
            client.Send("echo").Send("hello world");

            Console.WriteLine("Client received: " + client.Receive());
            Console.ReadKey();
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            //// create the server, configure echo command and start listening
            var server = new HumbleServer();

            server.AddCommand("echo", () => new EchoCommand());
            server.Start(0);

            //// create the client, connect to the server, send the command and the parameters
            var client = new HumbleClient();

            client.Connect("localhost", server.Port);
            client.Send("echo").Send("hello world");

            Console.WriteLine("Client received: " + client.Receive());
            Console.ReadKey();
        }
Exemplo n.º 4
0
        public bool Validar(TagConfiguracaoIp servico)
        {
            var configuracaoIp = this.unitOfWork
                                 .Obter(() => this.configuracaoIpRepositorio.ObterPorTag(servico.Value));

            if (configuracaoIp == null)
            {
                throw new Exception("Serviço não Iniciado. Serviço não está configurado para rodar nesse servidor. Verifique os parametros na tabela ipconfig que deve ter a tag [" + servico.Value + "]");
            }

            var ip = this.GetLocalIpAddress();

            if (ip != configuracaoIp.Host)
            {
                throw new Exception("Serviço não Iniciado. Este servidor não está autorizado a rodar este serviço. Verifique parametros na tabela ipconfig -> tag :: [" + servico.Value + "]");
            }

            var server = new HumbleServer();

            server.Start(configuracaoIp.Porta);

            return(true);
        }
Exemplo n.º 5
0
        public void Should_accept_differents_delimiters_for_differents_instances()
        {
            var server1 = new HumbleServer(Framing.Delimitered, "[DEL1]");
            var server2 = new HumbleServer(Framing.Delimitered, "[DEL2]");

            server1.AddCommand("echo", () => new EchoCommand());
            server2.AddCommand("echo", () => new EchoCommand());

            server1.Start(0);
            server2.Start(0);

            var client1 = new HumbleClient(Framing.Delimitered, "[DEL1]");
            var client2 = new HumbleClient(Framing.Delimitered, "[DEL2]");

            client1.Connect("localhost", server1.Port);
            client2.Connect("localhost", server2.Port);

            client1.Send("echohello1").Receive().ShouldEqual("hello1");
            client2.Send("echohello2").Receive().ShouldEqual("hello2");

            server1.Stop();
            server2.Stop();
        }
Exemplo n.º 6
0
 public void Setup()
 {
     Server = new HumbleServer().Start(0);
     BeforeTest();
 }
Exemplo n.º 7
0
 public void Setup()
 {
     Server = new HumbleServer().Start(0);
     BeforeTest();
 }