예제 #1
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.");
        }
예제 #2
0
        public void Client_Message_Server()
        {
            string message = "This is a test message.";

            SimpleSockets.Server.MessageReceivedDelegate msgRec = (client, msg) => {
                Assert.AreEqual(message, msg);
            };

            using (var monitor = new EventMonitor(_server, "MessageReceived", msgRec, Mode.MANUAL))
            {
                _client.SendMessage(message);
                monitor.Verify();
            }
        }