summaryrefslogtreecommitdiffstats
path: root/samples/IrcChatSystem/ChatCommonLib
diff options
context:
space:
mode:
authorHalil İbrahim Kalkan <hi_kalkan@yahoo.com>2013-04-08 21:44:58 +0300
committerHalil İbrahim Kalkan <hi_kalkan@yahoo.com>2013-04-08 21:44:58 +0300
commit79953cb56cda204f190ffcd9995b27ebea25e62d (patch)
treede939755c2e32eaa5fa3e41e21114e1c727ed0a4 /samples/IrcChatSystem/ChatCommonLib
parent934c543eb6b0bd7173038e45a7dac0241d091da4 (diff)
downloadscs-79953cb56cda204f190ffcd9995b27ebea25e62d.zip
scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.gz
scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.bz2
Adding to github
Adding to github
Diffstat (limited to 'samples/IrcChatSystem/ChatCommonLib')
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/ChatCommonLib.csproj67
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/ChatMessage.cs51
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/MessageTextStyle.cs71
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserInfo.cs27
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserStatus.cs23
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatClient.cs56
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatService.cs49
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/IrcChat/Exceptions/NickInUseException.cs40
-rw-r--r--samples/IrcChatSystem/ChatCommonLib/Properties/AssemblyInfo.cs36
9 files changed, 420 insertions, 0 deletions
diff --git a/samples/IrcChatSystem/ChatCommonLib/ChatCommonLib.csproj b/samples/IrcChatSystem/ChatCommonLib/ChatCommonLib.csproj
new file mode 100644
index 0000000..ff95d88
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/ChatCommonLib.csproj
@@ -0,0 +1,67 @@
+<?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)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{A57047DE-CC39-4C01-955E-D73888A0C83D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Hik.Samples.Scs</RootNamespace>
+ <AssemblyName>ChatCommonLib</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Debug\ChatCommonLib.XML</DocumentationFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Release\ChatCommonLib.XML</DocumentationFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Scs, Version=1.0.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="IrcChat\Arguments\ChatMessage.cs" />
+ <Compile Include="IrcChat\Arguments\MessageTextStyle.cs" />
+ <Compile Include="IrcChat\Exceptions\NickInUseException.cs" />
+ <Compile Include="IrcChat\Arguments\UserStatus.cs" />
+ <Compile Include="IrcChat\Contracts\IChatClient.cs" />
+ <Compile Include="IrcChat\Contracts\IChatService.cs" />
+ <Compile Include="IrcChat\Arguments\UserInfo.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/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/ChatMessage.cs b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/ChatMessage.cs
new file mode 100644
index 0000000..3fe595e
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/ChatMessage.cs
@@ -0,0 +1,51 @@
+using System;
+
+namespace Hik.Samples.Scs.IrcChat.Arguments
+{
+ /// <summary>
+ /// Represents a chat message that can be sent and received by chat users.
+ /// </summary>
+ [Serializable]
+ public class ChatMessage
+ {
+ /// <summary>
+ /// Message text.
+ /// </summary>
+ public string MessageText { get; set; }
+
+ ///<summary>
+ /// Text style of this message.
+ ///</summary>
+ public MessageTextStyle TextStyle { get; set; }
+
+ /// <summary>
+ /// Creates a new ChatMessage.
+ /// </summary>
+ public ChatMessage()
+ {
+ TextStyle = new MessageTextStyle();
+ MessageText = "";
+ }
+
+ /// <summary>
+ /// Creates a new ChatMessage.
+ /// </summary>
+ /// <param name="messageText">Message text</param>
+ public ChatMessage(string messageText)
+ {
+ TextStyle = new MessageTextStyle();
+ MessageText = messageText;
+ }
+
+ /// <summary>
+ /// Creates a new ChatMessage.
+ /// </summary>
+ /// <param name="messageText">Message text</param>
+ /// <param name="textStyle">Text style of this message</param>
+ public ChatMessage(string messageText, MessageTextStyle textStyle)
+ {
+ TextStyle = textStyle;
+ MessageText = messageText;
+ }
+ }
+} \ No newline at end of file
diff --git a/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/MessageTextStyle.cs b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/MessageTextStyle.cs
new file mode 100644
index 0000000..4467c22
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/MessageTextStyle.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Hik.Samples.Scs.IrcChat.Arguments
+{
+ /// <summary>
+ /// Represents text style of messages.
+ /// </summary>
+ [Serializable]
+ public class MessageTextStyle
+ {
+ /// <summary>
+ /// True, if message is sent as Bold.
+ /// </summary>
+ public bool IsBold { get; set; }
+
+ /// <summary>
+ /// True, if message is sent as italic.
+ /// </summary>
+ public bool IsItalic { get; set; }
+
+ /// <summary>
+ /// Font family of message.
+ /// </summary>
+ public string FontFamily { get; set; }
+
+ /// <summary>
+ /// Message text color.
+ /// </summary>
+ public Color TextColor { get; set; }
+
+ /// <summary>
+ /// Size of message text.
+ /// </summary>
+ public int TextSize { get; set; }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public MessageTextStyle()
+ {
+ FontFamily = "Verdana";
+ TextColor = new Color {Blue = 255, Green = 255, Red = 255};
+ TextSize = 12;
+ }
+
+ /// <summary>
+ /// Represents a color.
+ /// </summary>
+ [Serializable]
+ public class Color
+ {
+ /// <summary>
+ /// Red value of color.
+ /// </summary>
+ public byte Red { get; set; }
+
+ /// <summary>
+ /// Green value of color.
+ /// </summary>
+ public byte Green { get; set; }
+
+ /// <summary>
+ /// Blue value of color.
+ /// </summary>
+ public byte Blue { get; set; }
+ }
+ }
+}
diff --git a/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserInfo.cs b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserInfo.cs
new file mode 100644
index 0000000..c228e8b
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserInfo.cs
@@ -0,0 +1,27 @@
+using System;
+
+namespace Hik.Samples.Scs.IrcChat.Arguments
+{
+ /// <summary>
+ /// Represents a chat user.
+ /// This object particularly used in Login of a user.
+ /// </summary>
+ [Serializable]
+ public class UserInfo
+ {
+ /// <summary>
+ /// Nick of user.
+ /// </summary>
+ public string Nick { get; set; }
+
+ /// <summary>
+ /// Bytes of avatar of user.
+ /// </summary>
+ public byte[] AvatarBytes { get; set; }
+
+ /// <summary>
+ /// Status of user.
+ /// </summary>
+ public UserStatus Status { get; set; }
+ }
+}
diff --git a/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserStatus.cs b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserStatus.cs
new file mode 100644
index 0000000..2644f62
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Arguments/UserStatus.cs
@@ -0,0 +1,23 @@
+namespace Hik.Samples.Scs.IrcChat.Arguments
+{
+ /// <summary>
+ /// Represents state of a chat user.
+ /// </summary>
+ public enum UserStatus
+ {
+ /// <summary>
+ /// User if online and available for incoming messages.
+ /// </summary>
+ Available,
+
+ /// <summary>
+ /// User is busy and may not answer to messages.
+ /// </summary>
+ Busy,
+
+ /// <summary>
+ /// User is out.
+ /// </summary>
+ Out
+ }
+}
diff --git a/samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatClient.cs b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatClient.cs
new file mode 100644
index 0000000..bf24c2f
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatClient.cs
@@ -0,0 +1,56 @@
+using Hik.Communication.ScsServices.Service;
+using Hik.Samples.Scs.IrcChat.Arguments;
+
+namespace Hik.Samples.Scs.IrcChat.Contracts
+{
+ /// <summary>
+ /// This interface defines methods of chat client.
+ /// Defined methods are called by chat server.
+ /// </summary>
+ public interface IChatClient
+ {
+ /// <summary>
+ /// This method is used to get user list from chat server.
+ /// It is called by server once after user logged in to server.
+ /// </summary>
+ /// <param name="users">All online user informations</param>
+ void GetUserList(UserInfo[] users);
+
+ /// <summary>
+ /// This method is called from chat server to inform that a message
+ /// is sent to chat room publicly.
+ /// </summary>
+ /// <param name="nick">Nick of sender</param>
+ /// <param name="message">Message</param>
+ void OnMessageToRoom(string nick, ChatMessage message);
+
+ /// <summary>
+ /// This method is called from chat server to inform that a message
+ /// is sent to the current user privately.
+ /// </summary>
+ /// <param name="nick">Nick of sender</param>
+ /// <param name="message">Message</param>
+ void OnPrivateMessage(string nick, ChatMessage message);
+
+ /// <summary>
+ /// This method is called from chat server to inform that a new user
+ /// joined to chat room.
+ /// </summary>
+ /// <param name="userInfo">Informations of new user</param>
+ void OnUserLogin(UserInfo userInfo);
+
+ /// <summary>
+ /// This method is called from chat server to inform that an existing user
+ /// has left the chat room.
+ /// </summary>
+ /// <param name="nick">Informations of new user</param>
+ void OnUserLogout(string nick);
+
+ /// <summary>
+ /// This method is called from chat server to inform that a user changed his/her status.
+ /// </summary>
+ /// <param name="nick">Nick of the user</param>
+ /// <param name="newStatus">New status of the user</param>
+ void OnUserStatusChange(string nick, UserStatus newStatus);
+ }
+}
diff --git a/samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatService.cs b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatService.cs
new file mode 100644
index 0000000..5f554b2
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Contracts/IChatService.cs
@@ -0,0 +1,49 @@
+using Hik.Communication.ScsServices.Service;
+using Hik.Samples.Scs.IrcChat.Arguments;
+
+namespace Hik.Samples.Scs.IrcChat.Contracts
+{
+ /// <summary>
+ /// This interface defines Chat Service Contract.
+ /// It is used by Chat clients to interact with Chat Server.
+ /// </summary>
+ [ScsService(Version = "1.0.0.0")]
+ public interface IChatService
+ {
+ /// <summary>
+ /// Used to login to chat service.
+ /// </summary>
+ /// <param name="userInfo">User informations</param>
+ void Login(UserInfo userInfo);
+
+ /// <summary>
+ /// Sends a public message to room.
+ /// It will be seen by all users in room.
+ /// </summary>
+ /// <param name="message">Message to be sent</param>
+ void SendMessageToRoom(ChatMessage message);
+
+ /// <summary>
+ /// Sends a private message to a specific user.
+ /// Message will be seen only by destination user.
+ /// </summary>
+ /// <param name="destinationNick">Nick of the destination user
+ /// who will receive the message</param>
+ /// <param name="message">Message to be sent</param>
+ void SendPrivateMessage(string destinationNick, ChatMessage message);
+
+ /// <summary>
+ /// Changes status of a user and inform all other users.
+ /// </summary>
+ /// <param name="newStatus">New status of user</param>
+ void ChangeStatus(UserStatus newStatus);
+
+ /// <summary>
+ /// Used to logout from chat service.
+ /// Client may not call this method while logging out (in an application crash situation),
+ /// it will also be logged out automatically when connection fails between
+ /// client and server.
+ /// </summary>
+ void Logout();
+ }
+}
diff --git a/samples/IrcChatSystem/ChatCommonLib/IrcChat/Exceptions/NickInUseException.cs b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Exceptions/NickInUseException.cs
new file mode 100644
index 0000000..41f3424
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/IrcChat/Exceptions/NickInUseException.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Runtime.Serialization;
+
+namespace Hik.Samples.Scs.IrcChat.Exceptions
+{
+ /// <summary>
+ /// This exception is thrown by Chat server if a user wants to login
+ /// with a nick that is being used by another user.
+ /// </summary>
+ [Serializable]
+ public class NickInUseException : ApplicationException
+ {
+ /// <summary>
+ /// Contstructor.
+ /// </summary>
+ public NickInUseException()
+ {
+
+ }
+
+ /// <summary>
+ /// Contstructor.
+ /// </summary>
+ public NickInUseException(SerializationInfo serializationInfo, StreamingContext context)
+ : base(serializationInfo, context)
+ {
+
+ }
+
+ /// <summary>
+ /// Contstructor.
+ /// </summary>
+ /// <param name="message">Exception message</param>
+ public NickInUseException(string message)
+ : base(message)
+ {
+
+ }
+ }
+}
diff --git a/samples/IrcChatSystem/ChatCommonLib/Properties/AssemblyInfo.cs b/samples/IrcChatSystem/ChatCommonLib/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ffe4eba
--- /dev/null
+++ b/samples/IrcChatSystem/ChatCommonLib/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("ChatCommonLib")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("ChatCommonLib")]
+[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("c57972ac-fbe0-4cfa-ad54-70e1a3fc7dbc")]
+
+// 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")]