lifemate-sdk
v1.1.166
Published
###Every thing you need to create a professional live app
Downloads
24
Readme
lifemate-sdk
###Every thing you need to create a professional live app
MasterUserSocket
is the owner of the page , like manager of a company . this kind of user can manage the total politics of the app.
ApiUserSocket
acts as a middleware between clients and our servers . this socket which will handle the server to server tasks.
ClientUserSocket
is the socket which will handle the third party clients
after initializing the instance of lifemate :
LifeMateSession.initialize({
onRequestError: console.log,
onRequestSuccessful: () => {},
onRequestInitiating: () => {}
});
let's say your clients need to create a chat room , here is the procedure:
- client user will ask api user to create a chat room
const clientSocket = new ClientUserSocket({
onDirectEmit: () => {
},
onDirectRequest: (senderUserId, packet) => {
}
});
clientSocket.requestDirect(apiUserId,{
type: 'create-room',
data: 'any kind of data'
})
- api user received the packet and after applying page rules , will request the lifemate server to create a chat room
const apiSocket = new ApiUserSocket({
...
onDirectRequest: async (senderUserId: string,packet: Packet) => {
if(packet.type === 'create-room'){
...
// custom pageId codes
...
const room = await ClientService.chatRoomsApi().createChatRoom(pageId, 'my beloved room', ChatRoomType.DUO, { chat: true, fileTypes: [FileType.image, FileType.voice], videoCall: true, voiceCall: false }, {}, [senderUserId, 'anotherUserId']);
return room;
}
}
});
just like that
Access Control
| Method | MasterUser | ApiUser | ClientUser | | :--- | :---: | :---: | :--- | | CRUD api user | ✅ | | | | CRUD client user | | ✅ | | CRUD chat rooms | | ✅ | | | CRUD chat room members | | ✅ | | | send chat message | | | ✅| | send chat event | | ✅ | ✅| | send chat file | | | ✅| | create/delete conference room | | ✅ | | | enable/disable plugin |✅| | |
API Calls
POST /auth/signin
body:{
// mobile or email or username
mobileOrEmailOrUsername: string,
// required of the other field is username otherwise pass empty string. if the request does not include username ,an otp will be sent to the provided email or mobile number
password: string
}
POST /auth/signin/otp
request:
body:{
otp: string
}
response:
body:{
user: User
}
headers:{
set-cookie: [{authorization: jwt}]
}
POST /users/api-user
request:
body:{
username,
password,
name,
data
}
headers:{
authorization: string,
pageId: string
}
response:
body:{
credential: any,
jwt: string
}
POST /users/client-user
body:{
credential: any,
jwt: string
}
headers:{
authorization: string,
pageId: string
}
PATCH /users/state
body:{
data: any
}
headers:{
authorization: string,
pageId: string,
targetUserId: string
}