diff options
Diffstat (limited to 'samples/SimpleMessaging/ClientApp')
-rw-r--r-- | samples/SimpleMessaging/ClientApp/ClientApp.csproj | 61 | ||||
-rw-r--r-- | samples/SimpleMessaging/ClientApp/Program.cs | 51 | ||||
-rw-r--r-- | samples/SimpleMessaging/ClientApp/Properties/AssemblyInfo.cs | 36 |
3 files changed, 148 insertions, 0 deletions
diff --git a/samples/SimpleMessaging/ClientApp/ClientApp.csproj b/samples/SimpleMessaging/ClientApp/ClientApp.csproj new file mode 100644 index 0000000..58743d4 --- /dev/null +++ b/samples/SimpleMessaging/ClientApp/ClientApp.csproj @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{5F6A7126-4996-41AF-A4C1-13DA3D54C71B}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>ClientApp</RootNamespace> + <AssemblyName>ClientApp</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile>Client</TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <PlatformTarget>x86</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <PlatformTarget>x86</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Scs, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\Scs-Binaries\Scs.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/samples/SimpleMessaging/ClientApp/Program.cs b/samples/SimpleMessaging/ClientApp/Program.cs new file mode 100644 index 0000000..cfec50d --- /dev/null +++ b/samples/SimpleMessaging/ClientApp/Program.cs @@ -0,0 +1,51 @@ +using System; +using Hik.Communication.Scs.Client; +using Hik.Communication.Scs.Communication.EndPoints.Tcp; +using Hik.Communication.Scs.Communication.Messages; + +/* This program is build to demonstrate a client application that connects to a server + * and sends/receives messages in basic way of SCS framework. + */ + +namespace ClientApp +{ + class Program + { + static void Main() + { + //Create a client object to connect a server on 127.0.0.1 (local) IP and listens 10085 TCP port + var client = ScsClientFactory.CreateClient(new ScsTcpEndPoint("127.0.0.1", 10085)); + + //Register to MessageReceived event to receive messages from server. + client.MessageReceived += Client_MessageReceived; + + Console.WriteLine("Press enter to connect to the server..."); + Console.ReadLine(); //Wait user to press enter + + client.Connect(); //Connect to the server + + Console.Write("Write some message to be sent to server: "); + var messageText = Console.ReadLine(); //Get a message from user + + //Send message to the server + client.SendMessage(new ScsTextMessage(messageText)); + + Console.WriteLine("Press enter to disconnect from server..."); + Console.ReadLine(); //Wait user to press enter + + client.Disconnect(); //Close connection to server + } + + static void Client_MessageReceived(object sender, MessageEventArgs e) + { + //Client only accepts text messages + var message = e.Message as ScsTextMessage; + if (message == null) + { + return; + } + + Console.WriteLine("Server sent a message: " + message.Text); + } + } +}
\ No newline at end of file diff --git a/samples/SimpleMessaging/ClientApp/Properties/AssemblyInfo.cs b/samples/SimpleMessaging/ClientApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a10a169 --- /dev/null +++ b/samples/SimpleMessaging/ClientApp/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClientApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ClientApp")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("eee05ea3-074b-45e7-8cbf-8c4cf2ad4cf5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] |