Service

Essential services

Socket Store

SocketStore class is used to manage operation related to socket. It contains a store that includes mapping of userId with their socket. Also includes static methods such as addByUserId, getByUserId, removeByUserId, emitByUserId.

addByUserId()

  • Description: Used to add socket to the store with which user is connected to. This function maps between the socket and userId. By doing this we store all the sockets at one place that correspond to the user.
  • Parameter:

    • Name : userId

      Type: Schema.Types.ObjectId

      Description : unique userId

    • Name : socket

      Type: Object

      Description: Socket object to which user is connected to

  • Response:

    • Type : Object

      Description: Returns object with three properties: success (bool), message, data (which is to be sent).

getByuserId()

  • Description: Used to get all the socket objects to which user is connected.
  • Parameter:

    • Name : userId

      Type: Schema.Types.ObjectId

      Description : unique userId

  • Response:

    • Type : Object

      Description: Returns object with three properties: success (bool), message, data (which is to be sent).

emitByUserId()

  • Description: Emits an event to the user whose userId is provided in the parameters. This emits event to all the sockets to which user is connected.

  • Parameter:

    • Name : userId

      Type: Schema.Types.ObjectId

      Description : unique userId

    • Name : eventName

      Type: String

      Description: name of the event which to be emitted

    • Name : payload

      Type: Object

      Description: payload contains the data which has to be sent over the socket

removeByUserId()

  • Description: Removes the socket from the store.
  • Parameter:

    • Name : userId

      Type: Schema.Types.ObjectId

      Description : unique userId

    • Name : socketObj

      Type: Object

      Description: Socket object which is to be removed from the store

  • Response:

    • Type : Object

      Description: Returns object with three properties: success (bool), message, data (which is to be sent).

EmitToAll

  • Description: Used to emit a message or an object to everyone.

  • Parameter

  • Name: payload

    Type:Object

PushExpo

pushExpo class is used to send the push notification to the mobile devices. Depending on the pushToken received from the expo sdk.

sendNotification()

  • Description: Used to send notification to the MobileApp .
  • Parameter:

    • Name : userId

      Type: Schema.Types.ObjectId

      Description : unique userId

    • Name: pushToken

      Type: String

      Description: unique pushToken is allocted by expoSdk from mobileApp.

    • Name: notification

      Type: String

      Description: data that we want to send to the mobileApp .

  • Response:

    • Type : Object

      Description: Returns object with properties: receipt(incase of success) or error(incase of failure).

Optional services ( need to configure from adminDashboard )

smsApi

smsApi class is used to send the sms to the registered phone number. Depending on the events that are configured by admin from dashboard .

sendSms()

We have added twillio Sms services for sending out sms .

  • Description: Used to send sms to the registerd mobile number uses twillio Api .
  • Parameter:

    • Name : userId

      Type: Schema.Types.ObjectId

      Description : unique userId

    • Name: smsTesxt

      Type: String

      Description: content of the sms that you want to send to user.

  • Response:

    • Type : Object

      Description: Returns object with properties: result(incase of success) or error(incase of failure).

emailApi

emailApi class is used to send the email to the registered emailId of the user . Depending on the events that are configured by admin from dashboard .

sendEmail()

  • Description: Used to send email to the user's emailId .
  • Parameter:

    • Name : userId

      Type: Schema.Types.ObjectId

      Description : unique userId

    • Name: emailBody Type: object Description: emailBody object consists of email subject, text and the html template that we want to send to user .

  • Response:

    • Type : Object Description: Returns object with properties: info(incase of success) or error(incase of failure).

NOTE: In case if you are using email provider as gmail then you need to allow the less secure apps login from that account .

results matching ""

    No results matching ""