Ejemplo n.º 1
0
        public void Setup()
        {
            ManualResetEvent mre = new ManualResetEvent(false);

            _server = new SimpleSocketTcpListener();
            _client = new SimpleSocketTcpClient();

            new Thread(() => _server.StartListening(13000)).Start();

            ClientConnectedDelegate con = (client) =>
            {
                _clientid = client.Id;
                mre.Set();
            };

            _contract = new MessageContractImpl();
            _client.AddMessageContract(_contract);
            _server.AddMessageContract(_contract);

            _server.ClientConnected += con;

            _client.StartClient("127.0.0.1", 13000);

            mre.WaitOne(10000);
            _server.ClientConnected -= con;
        }
Ejemplo n.º 2
0
        private static void ClientTask()
        {
            //using (var client = new SimpleSocketTcpClient())
            //{
            var client = new SimpleSocketTcpClient();

            //var client = new SimpleSocketTcpSslClient(@"", "");
            _clientId++;
            client.MessageReceived   += ClientOnMessageReceived;
            client.ConnectedToServer += ClientOnConnectedToServer;
            client.ClientErrorThrown += ClientOnClientErrorThrown;
            client.MessageSubmitted  += ClientOnMessageSubmitted;
            client.MessageFailed     += ClientOnMessageFailed;
            client.StartClient("127.0.0.1", 13000);

            //Thread.Sleep(1000);

            for (int i = 0; i < _numMsg; i++)
            {
                Task.Delay(_random.Next(0, 25)).Wait();
                client.SendMessage("Test Message " + (i + 1));
            }

            //}

            Console.WriteLine("[CLIENT] has finished.");
        }
Ejemplo n.º 3
0
        private void initClient()
        {
            var client = new SimpleSocketTcpClient();

            _clients.Add(client);
            client.StartClient("127.0.0.1", 13000);
        }