TogetherChatRoom - TogetherGames/Public-Corona-Lua GitHub Wiki

TogetherChatRoom

Together::TogetherChatRoom

Overview

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


Members

number ChatRoomID

The ID of the ChatRoom.

number RoomID

The ID of the Room the ChatRoom is in.

number CreatorUserID

The ID of the User that created the ChatRoom.

string CreatorUsername

The username of the User that created the ChatRoom.

number SecondsSinceCreated

The number of seconds since the ChatRoom was created.

number 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.

table ChatRoomUsers

Contains all the ChatRoomUsers that are in the ChatRoom.

table ChatMessages

Contains all the ChatMessages belonging to the ChatRoom.


Methods


AddChatRoomUser()

Adds a ChatRoomUser to the internally managed list without persistence.

Note
This method is deprecated

Returns void
Syntax
TogetherChatRoom:AddChatRoomUser( chatRoomUser )
Parameters

TogetherChatRoomUser chatRoomUser

Instance of the ChatRoomUser to add internally

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

FindChatRoomUserByUserID()

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

Syntax
TogetherChatRoom:FindChatRoomUserByUserID( userID )
Parameters

number userID

The ID of the User to find

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

FindChatRoomUserByChatRoomUserID()

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

Syntax
TogetherChatRoom:FindChatRoomUserByChatRoomUserID( chatRoomUserID )
Parameters

number chatRoomUserID

The ID of the ChatRoomUser to find

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

GetChatRoomUserCount()

Gets the number of ChatRoomUsers currently managed internally.

Returns number
Syntax
TogetherChatRoom:GetChatRoomUserCount(  )

GetChatRoomUser()

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

Syntax
TogetherChatRoom:GetChatRoomUser( index )
Parameters

number index

The index of the ChatRoomUser to retrieve internally

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

IndexOfChatRoomUser()

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

Returns number
Syntax
TogetherChatRoom:IndexOfChatRoomUser( chatRoomUser )
Parameters

TogetherChatRoomUser 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 number
Syntax
TogetherChatRoom:IndexOfChatRoomUserByUserID( userID )
Parameters

number 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 number
Syntax
TogetherChatRoom:IndexOfChatRoomUserByChatRoomUserID( chatRoomUserID )
Parameters

number chatRoomUserID

The ID of the ChatRoomUser to find the index of

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

RemoveChatRoomUser()

Removes a ChatRoomUser from the internal list without persistence.

Note
This method is deprecated

Returns void
Syntax
TogetherChatRoom:RemoveChatRoomUser( index )
Parameters

number index

The index of the ChatRoomUser to remove

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

AddChatMessage()

Adds a ChatMessage to the internal list without persistence.

Note
This method is deprecated

Returns void
Syntax
TogetherChatRoom:AddChatMessage( chatMessage )
Parameters

TogetherChatMessage chatMessage

Instance of a ChatMessage to add internally

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

FindChatMessageByChatMessageID()

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

Syntax
TogetherChatRoom:FindChatMessageByChatMessageID( chatMessageID )
Parameters

number chatMessageID

The ID of the ChatMessage to find

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

GetChatMessageCount()

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

Returns number
Syntax
TogetherChatRoom:GetChatMessageCount(  )

GetChatMessage()

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

Syntax
TogetherChatRoom:GetChatMessage( index )
Parameters

number index

The index of the ChatMessage to find

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

IndexOfChatMessage()

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

Returns number
Syntax
TogetherChatRoom:IndexOfChatMessage( chatMessage )
Parameters

TogetherChatMessage 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 number
Syntax
TogetherChatRoom:IndexOfChatMessageByChatMessageID( chatMessageID )
Parameters

number chatMessageID

The ID of the ChatMessage to find the index of

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

RemoveChatMessage()

Removes a ChatMessage from the internal list without persistence.

Note
This method is deprecated

Returns void
Syntax
TogetherChatRoom:RemoveChatMessage( index )
Parameters

number index

The index of the ChatMessage to remove

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

GetDetails()

Gets the details on a ChatRoom.

Returns void
Syntax
TogetherChatRoom:GetDetails( chatRoomID, startWithChatMessageID, callbackFunc )
Parameters

number chatRoomID

The ID of the ChatRoom to get details on.

[number](#) startWithChatMessageID

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

[function](#) 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
TogetherChatRoom:Join( callbackFunc )
Parameters

function 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
TogetherChatRoom:Leave( callbackFunc )
Parameters

function 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
TogetherChatRoom:CreateMessage( parentChatMessageID, message, callbackFunc )
Parameters

number 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.

[function](#) 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
TogetherChatRoom:DeleteMessage( chatMessageID, callbackFunc )
Parameters

number chatMessageID

The ID of the ChatMessage to delete

[function](#) callbackFunc

The function to call upon completion.

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

MarkMessageAsRead()

Marks a Message as Read. Upon success, this will automatically update the ChatMessage internally.

Returns void
Syntax
TogetherChatRoom:MarkMessageAsRead( chatMessageID, callbackFunc )
Parameters

number chatMessageID

The ID of the ChatMessage to mark as read

[function](#) 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
TogetherChatRoom:Modify( callbackFunc )
Parameters

function 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
TogetherChatRoom:InviteUser( inviteeUserID, inviteeSocialType, inviteeSocialID, notificationMessage, callbackFunc )
Parameters

number 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 in "" if no notification is to be sent.

[function](#) callbackFunc

The function to call upon completion.

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