2.0.3 • Published 5 years ago

swizi-chat-sdk v2.0.3

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
5 years ago

Swizi chat SDK

This SDK allows to use Swizi Chat in your application. With this SDK you can connect to Chat Server with a end user, retrieve channels and other users, receive an send messages. This SDK is based on socket.io and is fully integrated with Swizi. It is possible to use it to chat with mobile apps generated with Swizi or with other software using this SDK.

Summary

  1. Installation
  2. Usage
  3. Events
  4. API

Breaking change

Since v1.2, ChatProxy is no more used. If no server is provided the default server used is https://api.chat.swizi.io

onDebug callback is no more used. To catch debug event, use on('debug', cb)

Message Type is now of two type : TEXT or MEDIA. MEDIA can be

Installation

npm i swizi-chat-sdk

or

yarn add swizi-chat-sdk

Note that a ReactJS is also available. See https://www.npmjs.com/package/react-swizi-chat

Usage

To use the SDK you need to things :

  • An API key to connect to chat server. This API key is provided with your Swizi Subscription.
  • The chat user identification

The user identification can be included in a token provided by Swizi (for exemple if your are in a Swizi mobile App) or it can be an ID provided by the Chat Service API.

The sequence to connect to a server is :

  • Create the ChatClient with server informations,
  • Configure the ChatClient with user informations and set the callback to get events,
  • Connect to server.

When the client is connected and authentified, events are sent to the callback and it is possible to send new messages with the postMessage method. See Events section to know all possible events.

Below a basic usage of ChatClient :

import ChatClient from 'SwiziChatClient'

let client = new ChatClient('https://api.chat.swizi.io')
client.configure('your user id', 'your api key')
client.on(ChatClient.EventType.AUTHENTIFIED, () => console.log("Ok I'm connected and authentified !"))
client.on(ChatClient.EventType.DEBUG, msg => console.debug(msg))

client.connect()

Events

Events are sent to callbacks when something happens on a channel. The callback function must contains two parameters : event and data.

Below are the events :

EventExplanation
ChatClient.EventType.CONFIGUREDChat client configuration is doneempty
ChatClient.EventType.CONNECTEDChat client is connected to serverempty
ChatClient.EventType.FAILEDConnexion to chat server failedError code
ChatClient.EventType.AUTHENTIFIEDUser is allowed by server and can start to chatempty
ChatClient.EventType.UNAUTHORIZEDUser is not allowed to use this chat server with this API Key
ChatClient.EventType.LOADEDAll rooms are loadedempty
ChatClient.EventType.DISCONNECTEDChat client is no more connectedempty
ChatClient.EventType.ROOM_UPDATEDAnswer to a "Update room" is arrivedempty
ChatClient.EventType.NEW_MESSAGEA new message is arrivedroomId
ChatClient.EventType.USER_INFO_UPDATEDAnswer to 'User Info' request is arrivedUser infos
ChatClient.EventType.USER_ANSWERING_STATUS_CHANGEDA user has sent a message to notify he is starting or ending writing a message
ChatClient.EventType.USER_LIST_RECEIVEDAnswer to "askForUsers" request is arrivedUsers list
ChatClient.EventType.NEW_ROOM_AVAILABLEA new room has been created for this userRoom information
ChatClient.EventType.USER_LIST_IN_PROGRESSaskForUsers request is running
ChatClient.EventType.USER_LIST_FAILEDaskForUsers request failed
ChatClient.EventType.REQUESTED_ROOM_CREATEDRequested new room was created
ChatClient.EventType.DEBUGDebug message is available
ChatClient.EventType.LIKE_CHANGEDA like counter changed on a message

API

API Documentation is available here : https://ms-desk.swizi.io/doc/Chat_Client_SDK_for_JS/

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.21

5 years ago

1.1.20

5 years ago

1.1.19

5 years ago

1.1.18

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago