'## Create service - eg- RoomService\n\n### Here we have a class RoomService which has multiple functionalities in it.\n\n### We have a *create* method which returns Promise gets data from params and then performs multiple checks, Such as If user has Permission to create room or not, whether the user who is requesting to create room exists or not, and then at the end *createRoom()* function is returned which was imported above \n\n```\nasync create(uid: string, params: ICreateRoomParams): Promise<IRoom> {\n const { type, name, members = [], readOnly, extraData, options } = params;\n <!-- Operations -->\n return createRoom(type, name, user.username, members, false, readOnly, extraData, options) as unknown as IRoom;\n}\n```',
'### 2 - Direct message\n\n### Here we have a method createDirectMessage method which helps in one to one communication in a dedicated room where 2 people can communicate, This method takes 2 arguments which are to and from which returns a Promise as rid. \n\n### Then a basic check is performed to check whether both users exist or not then at the end we return a imported function createDirectMessage\n\n```\nasync createDirectMessage({ to, from }: { to: string; from: string }): Promise<{ rid: string }> {\n <!-- Other operations such as searching for users -->\n return this.createDirectMessageWithMultipleUsers([toUser.username], fromUser._id); // This calls another function createDirectMessageWithMultipleUsers\n}\n```',
searchString:'async createDirectMessage({ to, from }: { to: string; from: string }): Promise<{ rid: string }> {',
searchString:'async createDirectMessage(',
},
{
title:"Create Direct Message with Multiple Users",
'## Creating DirectMessage\n\n### In previous step createDirectMessageWithMultipleUsers function was called and few data were passed on such as to users and from user, in createDirectMessageWithMultipleUsers we expect String Array of Members.\n\n```\n\tasync createDirectMessageWithMultipleUsers(members: string[], creatorId: string): Promise<{ rid: string }> { // Gets a list of memebers and creators id\n\t\treturn createDirectMessage(members, creatorId); // return createDirectMessage function\n }\n```\n\n### There are few more services and methods below, you can check them out',
"## onSend Function\n\n#### The onSend function sends a new message by calling the chat?.flows.sendMessage() method from useChat Context. It passes the value and tshow parameters as properties of an object and awaits the promise to resolve. The resolved value is stored in the newMessageSent variable.\n\n```\n const newMessageSent = await chat?.flows.sendMessage({ // Here chat.flows.sendMessage() is actually a property coming from ChatAPI. From here we are simply sending value to sendMessage property in ChatAPI\n text,\n tshow,\n\t});\n```\n",
'## ChatAPI sendMessage\n\n#### Among many properties and functions present in ChatAPI here we have sendMessage.\n\n#### Note that sendMessage is *readonly* implying that it cannot be modified after initialization. Hence Implementing ChatAPI in any class would make it modification possible.\n\n```\n readonly sendMessage: ({ text, tshow }: { text: string; tshow?: boolean }) => Promise<boolean>;\n```',