diff options
author | Halil İbrahim Kalkan <hi_kalkan@yahoo.com> | 2013-04-08 21:44:58 +0300 |
---|---|---|
committer | Halil İbrahim Kalkan <hi_kalkan@yahoo.com> | 2013-04-08 21:44:58 +0300 |
commit | 79953cb56cda204f190ffcd9995b27ebea25e62d (patch) | |
tree | de939755c2e32eaa5fa3e41e21114e1c727ed0a4 /samples/SimpleMessaging/SynchronizedClient | |
parent | 934c543eb6b0bd7173038e45a7dac0241d091da4 (diff) | |
download | scs-79953cb56cda204f190ffcd9995b27ebea25e62d.zip scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.gz scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.bz2 |
Adding to github
Adding to github
Diffstat (limited to 'samples/SimpleMessaging/SynchronizedClient')
3 files changed, 142 insertions, 0 deletions
diff --git a/samples/SimpleMessaging/SynchronizedClient/Program.cs b/samples/SimpleMessaging/SynchronizedClient/Program.cs new file mode 100644 index 0000000..aa7e3d2 --- /dev/null +++ b/samples/SimpleMessaging/SynchronizedClient/Program.cs @@ -0,0 +1,46 @@ +using System; +using Hik.Communication.Scs.Client; +using Hik.Communication.Scs.Communication.EndPoints.Tcp; +using Hik.Communication.Scs.Communication.Messages; +using Hik.Communication.Scs.Communication.Messengers; + +/* This program is build to demonstrate a client application that connects to a server + * and sends/receives messages in using SynchronizedMessenger. + */ + +namespace SynchronizedClient +{ + class Program + { + static void Main() + { + Console.WriteLine("Press enter to connect to the server..."); + Console.ReadLine(); //Wait user to press enter + + //Create a client object to connect a server on 127.0.0.1 (local) IP and listens 10085 TCP port + using (var client = ScsClientFactory.CreateClient(new ScsTcpEndPoint("127.0.0.1", 10085))) + { + //Create a SynchronizedMessenger that uses the client as internal messenger. + using (var synchronizedMessenger = new SynchronizedMessenger<IScsClient>(client)) + { + synchronizedMessenger.Start(); //Start synchronized messenger messenger + 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 a message to the server + synchronizedMessenger.SendMessage(new ScsTextMessage(messageText)); + + //Receive a message from the server + var receivedMessage = synchronizedMessenger.ReceiveMessage<ScsTextMessage>(); + + Console.WriteLine("Response to message: " + (receivedMessage.Text)); + + Console.WriteLine("Press enter to disconnect from server..."); + Console.ReadLine(); //Wait user to press enter + } + } + } + } +} diff --git a/samples/SimpleMessaging/SynchronizedClient/Properties/AssemblyInfo.cs b/samples/SimpleMessaging/SynchronizedClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6731277 --- /dev/null +++ b/samples/SimpleMessaging/SynchronizedClient/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("SynchronizedClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SynchronizedClient")] +[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("c705458e-5ba3-49fb-93e8-a3a813fb15b7")] + +// 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")] diff --git a/samples/SimpleMessaging/SynchronizedClient/SynchronizedClient.csproj b/samples/SimpleMessaging/SynchronizedClient/SynchronizedClient.csproj new file mode 100644 index 0000000..ae29c57 --- /dev/null +++ b/samples/SimpleMessaging/SynchronizedClient/SynchronizedClient.csproj @@ -0,0 +1,60 @@ +<?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>{256CA4BD-6131-4BD6-8EDB-BA9C2C706DA4}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>SynchronizedClient</RootNamespace> + <AssemblyName>SynchronizedClient</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"> + <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 |