Click here to Skip to main content
15,882,209 members
Articles / Programming Languages / C#

A Complete TCP Server/Client Communication and RMI Framework - Usage

Rate me:
Please Sign up or sign in to vote.
4.94/5 (102 votes)
12 Jun 2011CPOL22 min read 336.3K   26.1K   247  
An Open Source lightweight framework (named Simple Client Server Library (SCS)) that is delevoped to create Server/Client applications using the simple Remote Method Invocation mechanism.
<Window xmlns:my="clr-namespace:Hik.Samples.Scs.IrcChat.Controls"  x:Class="Hik.Samples.Scs.IrcChat.Windows.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SCS Chat Client" Height="517" Width="885" WindowStyle="SingleBorderWindow" WindowStartupLocation="CenterScreen" Closing="Window_Closing" Loaded="Window_Loaded" Icon="/ChatClientApp;component/Images/app_icon.ico">
    <Grid>
        <Grid Background="#FF1F1F1F">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="240" />
            </Grid.ColumnDefinitions>
            <my:MessagingAreaControl x:Name="messagingArea" />
            <StackPanel Grid.Column="1" Margin="5">
                <Border Margin="0,0,5,5" Height="80">
                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF393939" Offset="0" />
                            <GradientStop Color="Black" Offset="1" />
                        </LinearGradientBrush>
                    </Border.Background>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="80" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Border Margin="3" Grid.Column="0" BorderThickness="1" Background="#FF272626">
                            <Image Stretch="UniformToFill" Name="imgCurrentUserAvatar" />
                        </Border>
                        <StackPanel Grid.Column="1">
                            <Label Content="User Nick" Foreground="White" Height="Auto" Padding="2" Name="lblCurrentUserNick" Margin="3,1"></Label>
                            <ComboBox Name="cmbCurrentUserStatus" Margin="3,1" Background="#FF353535" SelectionChanged="cmbCurrentUserStatus_SelectionChanged" SelectedIndex="0" HorizontalContentAlignment="Left" VerticalContentAlignment="Stretch" IsReadOnly="False" BorderBrush="{x:Null}" Foreground="White" BorderThickness="0">
                                <ComboBoxItem HorizontalContentAlignment="Stretch"  Background="#FF353535" VerticalContentAlignment="Stretch">
                                    <Label Content="Available" Foreground="#FF2BE400" />
                                </ComboBoxItem>
                                <ComboBoxItem HorizontalContentAlignment="Stretch" Background="#FF353535" VerticalContentAlignment="Stretch">
                                    <Label Content="Busy" Foreground="#FFFF4E4E" />
                                </ComboBoxItem>
                                <ComboBoxItem HorizontalContentAlignment="Stretch" Background="#FF353535" VerticalContentAlignment="Stretch">
                                    <Label Content="Out" Foreground="#FF3179FE" />
                                </ComboBoxItem>
                            </ComboBox>
                        </StackPanel>
                    </Grid>
                </Border>
                <ScrollViewer VerticalScrollBarVisibility="Auto">
                    <StackPanel Name="spUsers" >
                    </StackPanel>
                </ScrollViewer>
            </StackPanel>
        </Grid>
        <Grid Background="White" Opacity="0.7" Name="grdConnect"></Grid>
        <Border Width="300" Height="115" Padding="2" Name="brdConnect" KeyDown="LoginForm_KeyDown">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="115" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Border Margin="2" BorderThickness="1" Background="#FF272626">
                    <Border.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Change to male" Click="ChangeToMale_Click" />
                            <MenuItem Header="Change to female" Click="ChangeToFemale_Click" />
                            <MenuItem Header="Select a picture..." Click="SelectAvatar_Click" />
                        </ContextMenu>
                    </Border.ContextMenu>
                    <Image Grid.Column="0" Stretch="UniformToFill" Name="imgLoginAvatar" StretchDirection="Both" />
                </Border>
                <Grid Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="80" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="26"/>
                        <RowDefinition Height="26"/>
                        <RowDefinition Height="26"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" Content="Nick:" Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" FontWeight="Bold" />
                    <Label Grid.Column="0" Grid.Row="1" Content="Server IP:" Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" FontWeight="Normal" />
                    <Label Grid.Column="0" Grid.Row="2" Content="Server Port:" Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" FontWeight="Normal" />
                    <TextBox Grid.Column="1" Grid.Row="0" Margin="2" Text="User Nick" FontWeight="Bold" VerticalContentAlignment="Center" Name="txtNick" TextChanged="txtNick_TextChanged"></TextBox>
                    <TextBox Grid.Column="1" Grid.Row="1" Margin="2" Text="127.0.0.1" VerticalContentAlignment="Center" Name="txtServerIpAddress"></TextBox>
                    <TextBox Grid.Column="1" Grid.Row="2" Margin="2" Text="10048" VerticalContentAlignment="Center" Name="txtServerPort"></TextBox>
                    <Button Grid.Column="1" Content="Login" Grid.Row="3" Margin="2" FontSize="15" FontWeight="Bold" Name="btnLogin" Click="btnLogin_Click" />
                </Grid>
            </Grid>
        </Border>
    </Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Volosoft
Turkey Turkey
I have started programming at 14 years old using Pascal as hobby. Then I interested in web development (HTML, JavaScript, ASP...) before university.

I graduated from Sakarya University Computer Engineering. At university, I learned C++, Visual Basic.NET, C#, ASP.NET and Java. I partly implemented ARP, IP and TCP protocols in Java as my final term project.

Now, I am working on Windows and web based software development mostly using Microsoft technologies in my own company.

My open source projects:

* ABP Framework: https://abp.io
* jTable: http://jtable.org
* Others: https://github.com/hikalkan

My personal web site:

https://halilibrahimkalkan.com

Comments and Discussions