ChatRoom - TogetherGames/Public-Unity-CSharp GitHub Wiki

ChatRoom

Together::ChatRoom

Overview

The ChatRoom class represents a ChatRoom and manages a list internally of ChatRoomUsers and ChatMessages


Members

long ChatRoomID

The ID of the ChatRoom.

long RoomID

The ID of the Room the ChatRoom is in.

long CreatorUserID

The ID of the User that created the ChatRoom.

string CreatorUsername

The username of the User that created the ChatRoom.

int SecondsSinceCreated

The number of seconds since the ChatRoom was created.

int SecondsSinceModified

The number of seconds since the ChatRoom was last modified.

string Name

The name of the ChatRoom.

string Description

A textual description for the ChatRoom.

PropertyCollection Properties

A property collection containing all custom properties for the ChatRoom.

List<ChatRoomUser> ChatRoomUsers

Contains all the ChatRoomUsers managed by the ChatRoom internally

List<ChatMessage> ChatMessages

Contains all the ChatMessages managed by the ChatRoom internally


Methods


AddChatRoomUser()

Adds a ChatRoomUser to the internally managed list.

Returns void
Syntax
ChatRoom.AddChatRoomUser( chatRoomUser )
Parameters

ChatRoomUser chatRoomUser

Instance of the ChatRoomUser to add internally

--------------------------------------------------------------------------------

FindChatRoomUserByUserID()

Finds the ChatRoomUser with the specified UserID if it exists, otherwise returns null.

Returns ChatRoomUser
Syntax
ChatRoom.FindChatRoomUserByUserID( userID )
Parameters

long userID

The ID of the User to find

--------------------------------------------------------------------------------

FindChatRoomUserByChatRoomUserID()

Finds the ChatRoomUser with the specified ChatRoomUserID if it exists, otherwise returns null.

Returns ChatRoomUser
Syntax
ChatRoom.FindChatRoomUserByChatRoomUserID( chatRoomUserID )
Parameters

long chatRoomUserID

The ID of the ChatRoomUser to find

--------------------------------------------------------------------------------

GetChatRoomUserCount()

Gets the number of ChatRoomUsers currently managed internally.

Returns int
Syntax
ChatRoom.GetChatRoomUserCount(  )

GetChatRoomUser()

Gets the ChatRoomUser at the specified index if it exists, otherwise returns null.

Returns ChatRoomUser
Syntax
ChatRoom.GetChatRoomUser( index )
Parameters

int index

The index of the ChatRoomUser to retrieve internally

--------------------------------------------------------------------------------

IndexOfChatRoomUser()

Returns the index of the specified ChatRoomUser if it exists internally, otherwise returns -1.

Returns int
Syntax
ChatRoom.IndexOfChatRoomUser( chatRoomUser )
Parameters

ChatRoomUser chatRoomUser

Instance of the chatRoomUser to find the index of

--------------------------------------------------------------------------------

IndexOfChatRoomUserByUserID()

Returns the index of the ChatRoomUser with the specified UserID if it exists, otherwise returns -1.

Returns int
Syntax
ChatRoom.IndexOfChatRoomUserByUserID( userID )
Parameters

long userID

The ID of the User to find the index of

--------------------------------------------------------------------------------

IndexOfChatRoomUserByChatRoomUserID()

Returns the index of the ChatRoomUser with the specified ChatRoomUserID if it exists, otherwise returns -1.

Returns int
Syntax
ChatRoom.IndexOfChatRoomUserByChatRoomUserID( chatRoomUserID )
Parameters

long chatRoomUserID

The ID of the ChatRoomUser to find the index of

--------------------------------------------------------------------------------

RemoveChatRoomUser()

Removes a ChatRoomUser from the internal list.

Returns void
Syntax
ChatRoom.RemoveChatRoomUser( index )
Parameters

int index

The index of the ChatRoomUser to remove

--------------------------------------------------------------------------------

AddChatMessage()

Adds a ChatMessage to the internal list.

Returns void
Syntax
ChatRoom.AddChatMessage( chatMessage )
Parameters

ChatMessage chatMessage

Instance of the ChatMessage to add

--------------------------------------------------------------------------------

FindChatMessageByChatMessageID()

Returns the ChatMessage with the specified ChatMessageID if it exists internally, otherwise returns null.

Returns ChatMessage
Syntax
ChatRoom.FindChatMessageByChatMessageID( chatMessageID )
Parameters

long chatMessageID

The ID of the ChatMessage to find

--------------------------------------------------------------------------------

GetChatMessageCount()

Gets the number of ChatMessages currently managed in the internal list.

Returns int
Syntax
ChatRoom.GetChatMessageCount(  )

GetChatMessage()

Gets the ChatMessage at the specified index if it exists, otherwise returns null.

Returns ChatMessage
Syntax
ChatRoom.GetChatMessage( index )
Parameters

int index

The index of the ChatMessage to retrieve

--------------------------------------------------------------------------------

IndexOfChatMessage()

Returns the index of the specified ChatMessage if it exists, otherwise returns -1.

Returns int
Syntax
ChatRoom.IndexOfChatMessage( chatMessage )
Parameters

ChatMessage chatMessage

Instance of the ChatMessage to retrieve the index of

--------------------------------------------------------------------------------

IndexOfChatMessageByChatMessageID()

Returns the index of the ChatMessage with the specified ChatMessageID if it exists, otherwise returns -1.

Returns int
Syntax
ChatRoom.IndexOfChatMessageByChatMessageID( chatMessageID )
Parameters

long chatMessageID

The ID of the ChatMessage to find

--------------------------------------------------------------------------------

RemoveChatMessage()

Removes a ChatMessage from the internal list.

Returns void
Syntax
ChatRoom.RemoveChatMessage( index )
Parameters

int index

The index of the ChatMessage to remove

--------------------------------------------------------------------------------

PostProcessUsernames()

Post processes the ChatRoomUser's and ChatMessage's usernames. If a User is registered, its Name member will be assigned the name from their social network account. Otherwise, the Name member will be set to the User's Username.

Returns void
Syntax
ChatRoom.PostProcessUsernames(  )

GetDetails()

Gets the details on a ChatRoom.

Returns void
Syntax
ChatRoom.GetDetails( chatRoomID, startWithChatMessageID, callbackFunc )
Parameters

long chatRoomID

The ID of the ChatRoom to get details on.

[long](#) startWithChatMessageID

ID of the ChatMessage to start with when the server retrieves chat messages.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Join()

Joins the current session and user to this ChatRoom. Upon success, this will automatically update the internal list.

Note
Be sure to set the class's ChatRoomID member to the ID of the ChatRoom you wish to join.

Returns void
Syntax
ChatRoom.Join( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Leave()

Disconnects the current session and user from this ChatRoom.

Note
Be sure to set the class's ChatRoomID member to the ID of the ChatRoom you wish to leave.

Returns void
Syntax
ChatRoom.Leave( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

CreateMessage()

Creates a new ChatMessage and adds it to this ChatRoom. Upon success, this will automatically update the internal list.

Note
Be sure to set the class's ChatRoomID member to the ID of the ChatRoom you wish to join.

Returns void
Syntax
ChatRoom.CreateMessage( parentChatMessageID, message, callbackFunc )
Parameters

long parentChatMessageID

The ID of the ChatMessage that is to be the parent of the newly created ChatMessage. Pass in 0 if the ChatMessage is not to have a parent.

[string](#) message

The message to assign to the ChatMessage.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

DeleteMessage()

Deletes a ChatMessage from the ChatRoom. Upon success, this will automatically update the internal list.

Note
Be sure to set the class's ChatRoomID member to the ID of the ChatRoom you wish to delete.

Returns void
Syntax
ChatRoom.DeleteMessage( chatMessageID, callbackFunc )
Parameters

long chatMessageID

The ID of the ChatMessage to delete.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

MarkMessageAsRead()

Marks a Message as Read. Upon success, this will automatically update the ChatMessage internally. Be sure to set the class's ChatRoomID member to the ID of the ChatRoom you wish to join.

Returns void
Syntax
ChatRoom.MarkMessageAsRead( chatMessageID, callbackFunc )
Parameters

long chatMessageID

The ID of the ChatMessage to mark as read.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Modify()

Modifies the ChatRoom. Upon success, this will automatically update the ChatRoom internally. With this method, you can modify the following parameters of the ChatRoom: RoomID, Name, Description, ChatRoomProps.

Note
Be sure to set the class's ChatRoomID member to the ID of the ChatRoom you wish to modify.

Returns void
Syntax
ChatRoom.Modify( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

InviteUser()

Invites a User to this ChatRoom. You must either specify a valid inviteeUserID or valid inviteeSocialType and inviteeSocialID. For Facebook, pass in "FB" for inviteeSocialType and the friend's FacebookID for inviteeSocialID.

Note
Be sure to set the class's ChatRoomID member to the ID of the ChatRoom you wish the User to be invited to.

Returns void
Syntax
ChatRoom.InviteUser( inviteeUserID, inviteeSocialType, inviteeSocialID, notificationMessage, callbackFunc )
Parameters

long inviteeUserID

The ID of the User to invite. Pass in 0 if not specified.

[string](#) inviteeSocialType

The type of social network. Pass in "" if not specified. "FB" for Facebook.

[string](#) inviteeSocialID

The ID of the social friend. Pass in "" if not specified. Friends's FacebookID otherwise.

[string](#) notificationMessage

The message to use when creating a UserNotification for the User being invite. Pass "" if no notification is to be sent.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------
⚠️ **GitHub.com Fallback** ⚠️