summaryrefslogtreecommitdiffstats
path: root/samples/IrcChatSystem/ChatClientApp/Client/ChatClient.cs
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/ChatClientApp/Client/ChatClient.cs
parent934c543eb6b0bd7173038e45a7dac0241d091da4 (diff)
downloadscs-79953cb56cda204f190ffcd9995b27ebea25e62d.zip
scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.gz
scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.bz2
Adding to github
Adding to github
Diffstat (limited to 'samples/IrcChatSystem/ChatClientApp/Client/ChatClient.cs')
-rw-r--r--samples/IrcChatSystem/ChatClientApp/Client/ChatClient.cs103
1 files changed, 103 insertions, 0 deletions
diff --git a/samples/IrcChatSystem/ChatClientApp/Client/ChatClient.cs b/samples/IrcChatSystem/ChatClientApp/Client/ChatClient.cs
new file mode 100644
index 0000000..709df89
--- /dev/null
+++ b/samples/IrcChatSystem/ChatClientApp/Client/ChatClient.cs
@@ -0,0 +1,103 @@
+using System;
+using Hik.Samples.Scs.IrcChat.Arguments;
+using Hik.Samples.Scs.IrcChat.Contracts;
+
+namespace Hik.Samples.Scs.IrcChat.Client
+{
+ /// <summary>
+ /// This class implements IChatClient to use to be invoked by Chat Server.
+ /// </summary>
+ internal class ChatClient : IChatClient
+ {
+ #region Private fields
+
+ /// <summary>
+ /// Reference to Chat Room window.
+ /// </summary>
+ private readonly IChatRoomView _chatRoom;
+
+ #endregion
+
+ #region Constructor
+
+ /// <summary>
+ /// Creates a new ChatClient.
+ /// </summary>
+ /// <param name="chatRoom">Reference to Chat Room window</param>
+ public ChatClient(IChatRoomView chatRoom)
+ {
+ _chatRoom = chatRoom;
+ }
+
+ #endregion
+
+ #region IChatClient implementation
+
+ /// <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>
+ public void GetUserList(UserInfo[] users)
+ {
+ foreach (var user in users)
+ {
+ _chatRoom.AddUserToList(user);
+ }
+ }
+
+ /// <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 text</param>
+ public void OnMessageToRoom(string nick, ChatMessage message)
+ {
+ _chatRoom.OnMessageReceived(nick, message);
+ }
+
+ /// <summary>
+ /// This method is called from chat server to inform that a message
+ /// is sent to the current used privately.
+ /// </summary>
+ /// <param name="nick">Nick of sender</param>
+ /// <param name="message">Message</param>
+ public void OnPrivateMessage(string nick, ChatMessage message)
+ {
+ _chatRoom.OnPrivateMessageReceived(nick, 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>
+ public void OnUserLogin(UserInfo userInfo)
+ {
+ _chatRoom.AddUserToList(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>
+ public void OnUserLogout(string nick)
+ {
+ _chatRoom.RemoveUserFromList(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>
+ public void OnUserStatusChange(string nick, UserStatus newStatus)
+ {
+ _chatRoom.OnUserStatusChange(nick, newStatus);
+ }
+
+ #endregion
+ }
+}