# JSDoc: Class: chatBuffer

# Class: chatBuffer

## chatBuffer(server, chanDB, channel)

Class representing a stored chat buffer

## Constructor

#### new chatBuffer(server, chanDB, channel)

Instantiates a new chat buffer for a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`server` | channelManager | Parent Server Object
`chanDB` | Mongoose.Document | chanDB to rehydrate buffer from
`channel` | activeChannel | Parent Channel Object

Source:
  - app/channel/chatBuffer.js, line 22

### Methods

#### handleBusyRoom()

Called after 5 minutes of solid activity

Source:
  - app/channel/chatBuffer.js, line 94

#### handleInactivity()

Called after 10 seconds of chat room inactivity

Source:
  - app/channel/chatBuffer.js, line 87

#### push(chat)

Adds a given chat to the chat buffer in RAM and sets any appropriate timers for DB transactions

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat object to commit to buffer

Source:
  - app/channel/chatBuffer.js, line 57

#### (async) saveDB(reason, chanDB)

Saves RAM-Based buffer to Channel Document in DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`reason` | String | Reason for DB save, formatted as 'x minutes/seconds of in/activity', used for logging purposes
`chanDB` | Mongoose.Document | Channel Doc to work with, can be left empty for method to auto-find through channel name.

Source:
  - app/channel/chatBuffer.js, line 103

#### shift()

Removes the oldest item from the chat buffer Was originally created in-case we needed to trigger timing functions Left here since it seems like good form anywho, since this would be a private, or at least protected member in another language

Source:
  - app/channel/chatBuffer.js, line 80