ChatBox - Functions

Here is a list of available functions that can be called on the ChatBox component. Seperated out by client and server calls.

Client Functions

Function Description
SetIDofChannelToJoin(string id) Sets the value of the channelToJoin internal variable.
SetNameOfChannelToCreate(string input) Sets the value of the channelToCreate internal variable.
RequestCreateChannel() Will send a request to the server to make a new chat channel according to the channelToCreate internal value (set via SetNameOfChannelToCreate)
RequestCreateChannel(string channelName) Will send a request to the server to make a new chat channel according to the passed in string value
RegisterWithChannel(int id) Will send a request to the server to join the chat channel with the specified id
RegisterWithChannel() Will send a request to the server to join the chat channel according to the channelToJoin value (set via SetIDofChannelToJoin)
RequestLeaveActiveChannel() Will send a request to the server leave your current activeChannel
RequestInviteToChannel() Will send a request to the server to invite clients in the inviteList (set previously) to your current activeChannel
PurgeInviteList() Will wipe the inviteList
UpdateInviteList(int clientId, bool add=true) Will either add or remove a clientId to the inviteList
ReceivedInviteToChannel(ServerInvitedToChannel data) Called on a client via the server with that client has received a new invite.
JoinChannel(string channelName, int id) Will add yourself to a joinedChannels entry and remove it from invitedChannel.
LeaveChannel(int id) Will remove the entry from joinedChannels
CreateChannel(string channelName, int id) Used as a callback to generate a button (channelButton) component as a child of channelParent.
PurgeChannelList() Destroys all children of channelParent
SetActiveChannel(int id) Set the activeChannel to the specified value, triggers PurgeMessages and SetMessages
ReceiveServerCreatedChannel(ServerCreatedChannel data) Called on client via server when a client receives a success message from server regarding a request to create a new chat channel.
ReceiveChannelRegistrationSuccess(ServerSuccessfullyRegistered data) Called on client via server when a client receives a success message from server regarding their request to register/join a chat channel.
ReceiveChannelMembersUpdated(ServerUpdateChannelMembers data) Called on client via server when a new client has joined a channel they are a member of.
RefreshChannels() Calls PurgeChannelList and CreateChannel functions to regenerate the channel button list.
GetMessageHistory(List channels) Client requests server to send the stored channel history for the specified list of channel ids.
SendMessage() Client sends message data to the server according to whatever is in the messageInput's text.
ReceiveChatMessage(ServerChatMessage data) Server triggers this on clients when a new message for a channel they are a member of is received by the server.
ReceiveMessageHistory(ServerMessageHistory data) Server is responding back with the desired message history for a channel according to the clients original GetMessageHistory request.

Server Functions

Function Description
NewClientConnectedToServer(NetworkConnection conn) Called via mirror internal logic when a new NetworkConnection appears on the server. Updates the channelMembers dictionary, which in turn will call ReceiveChannelMembersUpdated on clients.
ClientDisconnected(NetworkConnection conn) Called via mirror internal logic when a new NetworkConnection appears on the server. Updates the channelMembers dictionary, which in turn will call ReceiveChannelMembersUpdated on clients.
ClientInvitedToChannel(NetworkConnection clientConn, ClientInviteToChannel data) Called on server via client when a client wants the server to invite a series of other clients to a target channel id. Will trigger ReceivedInviteToChannel on other effected clients.
ClientRequestLeaveChannel(NetworkConnection clientConn, ClientLeaveChannel data) Called on server via client when a client wants to leave a target chat channel. If allowed will update channelMembers, which calls ReceiveChannelMembersUpdated on all effected clients.
ClientRegisteredWithChannel(NetworkConnection clientConn, ClientRegisterWithChannel data) Called on server via client when a client wants to register themselves with a chat channel. If successfull will trigger ReceiveChannelRegistrationSuccess on the requesting client
ClientRequestedNewChannel(NetworkConnection clientConn, ClientCreateChannel data) Called on server via client when a client wants to make a new chat channel. If successfull will trigger ReceiveServerCreatedChannel on the requesting client.
ClientChatMessage(NetworkConnection sendingClientConn, ClientChatMessage data) Called on server via client when a client sends new chat data to a channel. Forwards this data to every client that is currently a member of that channel.
ClientRequestedHistory(NetworkConnection requestingClient, ClientMessageHistory data) Called on server via client when a client request the chat history for a list of channels. Will trigger ReceiveMessageHistory on the client if successfully found channel and they are a member of it.