Click or drag to resize
ChatService Class
Implementation of chat service. All chat operations made from client goes through this service.
Inheritance Hierarchy

Namespace: CMS.Chat
Assembly: CMS.Chat (in CMS.Chat.dll) Version: 8.2.23
Syntax
C#
public class ChatService : ChatServiceBase, 
	IChatService

The ChatService type exposes the following members.

Constructors
  NameDescription
Public methodChatService
Top
Methods
  NameDescription
Public methodAcceptChatRequest
Accepts initiated chat request.
Public methodAcceptInvitation
Accepts invitation: - closes specified notification - inserts user into room (joins) - sends notification to sender about accepting invite
Public methodAddAdmin
Adds admin to the room. Only admin can do it.
Public methodCloseAllNotifications
Closes (markes as read) all notifications which belongs to online users and which were sent until untilWhen.
Public methodCloseNotification
Closes (markes as read) specified notification. This can be used to close generic notifications like InvitationDeclined or InvitationAccepted.
Public methodCreateChatRoom
Creates new chat room. Current user have to join it manually after creating it. Code name of this room will be: chatroom_{current_user_id}_{new_guid}
Public methodCreateOneToOneChatRoom
Creates new one-to-one chat room which will be accessible by current user and one more user (invited one). Display name of new room will be: {nickname_current} - {nickname_invited} Code name will be: adhoc_{id_lower}-{id_upper} ({id_lower} is the lower id of the two chat users, {id_upper} is the upper one). A current user have to manually join this room after creating it. If those two users have chatted before, the previously created room is returned. Code name is used to find previously created chat room.
Public methodCreateSupportChatRoom
Creates new support room. Support room is private room which can be accessed only by creator and support. When creator writes to this room, support is notified.
Public methodCreateSupportChatRoomManual
Creates new support room. Support room is private room which can be accessed only by creator and support. When creator writes to this room, support is notified. This room does not have default greeting message, but messages passed as parameter.
Public methodDeclineChatRequest
Declines initiated chat request.
Public methodDeclineInvitation
Declines invitation: - closes specified notification - sends notification to sender about declining invite
Public methodDeleteAdmin
Deletes admin from the room. Only admin can do it.
Public methodDeleteChatRoom
Disables room. User has to be either Global admin, has ManageRooms permission or be creator/admin of this room.
Protected methodGetChatResponse(ChatResponseStatusEnum)
Builds general chat response with error set to statusCode and message set to default value associated with statusCode.
(Inherited from ChatServiceBase.)
Protected methodGetChatResponse(ChatResponseStatusEnum, String)
Builds general chat response with error set to statusCode and message set to statusMessage.
(Inherited from ChatServiceBase.)
Protected methodGetChatResponseTData(ChatResponseStatusEnum, String, TData)
Builds generic ChatGeneral response with properties set to passed params.
(Inherited from ChatServiceBase.)
Public methodGetChatUserState
Gets info about currently logged in chat user.
Protected methodGetOkChatResponse
Builds general chat response with OK code.
(Inherited from ChatServiceBase.)
Protected methodGetOkChatResponseTData(TData)
Builds general chat response with OK code and Data set to data.
(Inherited from ChatServiceBase.)
Public methodGetPermissions
Gets permissions of currently logged in user.
Public methodGetSupportEngineersOnlineCount
Gets count of currently logged in support engineers.
Public methodChangeChatRoom
Changes existing chat room.
Public methodChangeMyNickname
Changes nickname of currently logged in user.
Public methodInviteToRoom
Invites user to the chat room. Invitation is inserted into the second user's notifications. Second user can enter the room after accepting the invitation. Current user has to have admin rights to the room to invite.
Public methodJoinRoom
Joins a room. Chat user has to be logged in before this operation.
Public methodKickUser
Kicks a chat user from a room. Currently logged user must be an admin to kick another user.
Public methodKickUserPermanently
Kickes user permanently from a private room. If this room is public, it acts as a normal kick. Kicked user won't be able to enter room again, unless he will be invited one more time.
Public methodLeaveRoom
Leaves chat room.
Public methodLeaveRoomPermanently
Permanently leaves current user from the private chat room (Join/Admin rights are removed from this room). If room is not private, it acts as normale LeaveRoom().
Public methodLogout
Logouts chat user from chat (not CMSUser). Leaves all rooms. If CMSUser is logged in, this operation won't logout the chat user in reality.
Public methodPing
Keeps user online in global list of chat online users (this method needs to be called periodically). Checks if there were any changes in: - rooms (new room added, changed name, etc.) since lastRoomsChange. - counts of users in rooms since lastUsersInRoomsChange. - global online users since lastOnlineUsersChange. - notifications for online user since lastNotificationChange. If any of this objects has changed, changes are send back to client. If any of params is null, its objects are not checked. If param is 0, it is the first request and all objects are returned. If user is not online on chat, only CurrentChatUserState will be returned and data (rooms, online users, etc.) will be null.
Public methodPingInitiate
Checks if there is new initiated chat request pending for this user and returns it. Returns null if there is nothing. Requests are searched by ContactID and UserID.
Public methodPingRoom

Keeping alive user in a room. User has to call this method every few seconds to let server know that he is still online.

At the same time a new online users in a room and a new messages in a room are checked. Client sends the last time he made an update of online users (roomUsersLastChange) and messages (roomMessagesLastChange). If something new has happened since that time, the changes are sent back.

Public methodPostMessage
Posts a new message to a room. Chat user has to be logged in and joined this room. Message can not be empty.
Public methodPostMessageToUser
Posts a whisper message to user. This message will be posted to a room, but only sender and receiver of this messages will be able to see it.
Public methodRegister
Registers new anonymous chat user. This new user is automatically logged in.
Public methodRegisterGuest
Registers new guest user (user with auto generated nickname).
Public methodRejectMessage
Rejects the message. Checks for permissions for a specified room (roomID can be get from messageID) and if current chat user has admin rights, it rejects the message.
Public methodSearchOnlineUsers
Search users who are online globally on a chat (they are performing Ping()) and meet condition (their nickname contains nickname.
Protected methodVerifyChatUserHasAdminRoomRights
Verifies that currently logged in chat user has admin rights for a room. Throws exception in case of failure and does nothing in case of success.
(Inherited from ChatServiceBase.)
Protected methodVerifyChatUserHasAllPermissions
Verifies that currently logged in chat user has all of the passed permissions. Throws exception in case of failure and does nothing in case of success.
(Inherited from ChatServiceBase.)
Protected methodVerifyChatUserHasAnyPermission
Verifies that currently logged in chat user has at least one of the passed permissions. Throws exception in case of failure and does nothing in case of success.
(Inherited from ChatServiceBase.)
Protected methodVerifyChatUserHasPermission
Verifies that currently logged in chat user has specified permission. Throws exception in case of failure and does nothing in case of success.
(Inherited from ChatServiceBase.)
Protected methodVerifyChatUserIsLoggedIn
Verifies that chat user is logged in. Throws exception in case of failure and does nothing in case of success.
(Inherited from ChatServiceBase.)
Protected methodVerifyChatUserIsOnlineInARoom
Verifies that currently logged in chat user is online in a room. Throws exception in case of failure and does nothing in case of success.
(Inherited from ChatServiceBase.)
Protected methodVerifyIPIsNotBanned
Verifies that IP addres which was used to make this request is not banned. Throws exception in case of failure and does nothing in case of success.
(Inherited from ChatServiceBase.)
Top
Extension Methods
  NameDescription
Public Extension MethodAsValue
Converts object to a query value which can be used as a query parameter
(Defined by QueryExtensions.)
Public Extension MethodGetAPIString
Gets the string by the specified resource key
(Defined by CoreExtensions.)
Public Extension MethodGetString
Gets the string by the specified resource key
(Defined by CoreExtensions.)
Public Extension MethodToBoolean
Returns the boolean representation of an object or default value if not.
(Defined by CoreExtensions.)
Public Extension MethodToDateTime
Returns the DateTime representation of an object or default value if not.
(Defined by CoreExtensions.)
Public Extension MethodToDouble
Returns the double representation of an object or default value if not.
(Defined by CoreExtensions.)
Public Extension MethodToGuid
Returns the Guid representation of an object or default value if not.
(Defined by CoreExtensions.)
Public Extension MethodToInteger
Returns the integer representation of an object or default value if not.
(Defined by CoreExtensions.)
Public Extension MethodToString
Returns the string representation of an object or default value if not.
(Defined by CoreExtensions.)
Top
Properties
  NameDescription
Protected propertyCurrentChatUserState
Gets ChatUserState of currently logged in chat user.
(Inherited from ChatServiceBase.)
Protected propertyIsIPBanned
Gets true if current user's IP address is banned and he can not do anything on the chat.
(Inherited from ChatServiceBase.)
Protected propertySites
Shortcut to ChatGlobalData.Instance.Sites (contains cached chat objects (rooms, etc.)).
(Inherited from ChatServiceBase.)
Top
See Also