Example #1
0
        private static void NameReceive(DestinationClient client, UserInput value)
        {
            var name = value.Input;

            clients[client] = name;
            Console.WriteLine($"{client.RemoteEndPoint} now is {name}");
        }
Example #2
0
        private static void MessageReceive(DestinationClient client, UserInput value)
        {
            var senderName = clients[client];
            var message    = value.Input;

            Console.WriteLine($"{senderName} say: {message}");
            var userMassage = new UserMessage(senderName, message);

            foreach (var otherClient in clients)
            {
                otherClient.Key.Send((int)ScEventId.SendUserMessage, userMassage);
            }
        }
Example #3
0
        public void Group_Add_ShouldNotAddClientFromOtherServer()
        {
            var additionalServer = new FlowServer()
                                   .UsingModule(new TcpModule(LocalAddress, Port2))
                                   .Start();

            DestinationClient additionalClient = null;

            additionalServer.ClientConnected += c => additionalClient = c;

            new FlowClient(LocalAddress, Port2).Connect();

            var group = new FlowGroup(server);

            Assert.Throws(typeof(Exception), () => group.Add(additionalClient));
        }
Example #4
0
        private async void AcceptHandler()
        {
            try
            {
                while (working)
                {
                    var client = await listener.AcceptTcpClientAsync();

                    var destinationClient = new DestinationClient(new TcpProtocol(client), owner, client.Client.RemoteEndPoint);
                    owner.ConnectMe(destinationClient);
                }
            }
            catch (ObjectDisposedException exception)
            {
                if (working)
                {
                    throw;
                }
            }
        }
Example #5
0
 private static void Server_ClientDisconnected(DestinationClient client)
 {
     Console.WriteLine($"{(clients.ContainsKey(client) ? clients[client] : client.RemoteEndPoint.ToString())} disconnected");
     clients.Remove(client);
 }
Example #6
0
 private static void Server_ClientConnected(DestinationClient client)
 {
     Console.WriteLine($"Someone connected on {client.RemoteEndPoint}");
     client.Send((int)ScEventId.SendUserMessage, new UserMessage("Server", "What is your name?"));
 }