Example #1
0
        private void ClientConnected(object sender, ClientAcceptEventArgs e)
        {
            var clientConnection = e.AcceptedConnection;
            var serverSocket     = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            serverSocket.Connect(this.txtOtherServer.Text, (int)this.numRealGSPort.Value);
            var socketConnection = SocketConnection.Create(serverSocket);
            var encryptor        = new PipelinedXor32Encryptor(new PipelinedSimpleModulusEncryptor(socketConnection.Output, PipelinedSimpleModulusEncryptor.DefaultClientKey).Writer);
            var decryptor        = new PipelinedSimpleModulusDecryptor(socketConnection.Input, PipelinedSimpleModulusDecryptor.DefaultClientKey)
            {
                AcceptWrongBlockChecksum = true
            };
            var serverConnection = new Connection(socketConnection, decryptor, encryptor);
            var proxy            = new Proxy(clientConnection, serverConnection, this.InvokeByProxy);

            this.InvokeByProxy(new Action(() =>
            {
                this.proxiedConnections.Add(proxy);
                if (this.proxiedConnections.Count == 1)
                {
                    this.connectedClientsListBox.SelectedItem = proxy;
                    this.ConnectionSelected(this, EventArgs.Empty);
                }
            }));
        }
Example #2
0
        private void ChatClientAccepted(object sender, ClientAcceptEventArgs e)
        {
            var chatClient = new ChatClient(e.AcceptedConnection, this.manager);

            this.connectedClients.Add(chatClient);
            chatClient.Disconnected += this.ChatClient_Disconnected;
        }