Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ Test credentials:

Installation and usage documentation could be found here [EmbeddedChat installation and usage](https://rocketchat.github.io/EmbeddedChat/docs/docs/Usage/embeddedchat_setup)

### Matrix Support (Experimental)

EmbeddedChat now supports connecting to a Matrix homeserver.

To use Matrix mode, set the `mode` prop to `'matrix'` and provide the `host` and `roomId`.

```jsx
<EmbeddedChat
mode="matrix"
host="https://matrix.org"
roomId="!roomId:matrix.org"
/>
```

## Development

### Local Setup
Expand Down
3 changes: 2 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"@embeddedchat/auth": "workspace:^",
"@rocket.chat/sdk": "^1.0.0-alpha.42"
"@rocket.chat/sdk": "^1.0.0-alpha.42",
"matrix-js-sdk": "^39.3.0-rc.0"
}
}
3 changes: 2 additions & 1 deletion packages/api/src/EmbeddedChatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
RocketChatAuth,
ApiError,
} from "@embeddedchat/auth";
import { IChatProvider } from "./IChatProvider";

// mutliple typing status can come at the same time they should be processed in order.
let typingHandlerLock = 0;
export default class EmbeddedChatApi {
export default class EmbeddedChatApi implements IChatProvider {
host: string;
rid: string;
rcClient: Rocketchat;
Expand Down
34 changes: 34 additions & 0 deletions packages/api/src/IChatProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { RocketChatAuth } from "@embeddedchat/auth";

export interface IChatProvider {
sendTypingStatus(username: string, typing: boolean): Promise<void>;

addMessageListener(callback: (message: any) => void): void;
removeMessageListener(callback: (message: any) => void): void;
addMessageDeleteListener(callback: (messageId: string) => void): void;
removeMessageDeleteListener(callback: (messageId: string) => void): void;
addTypingStatusListener(callback: (users: string[]) => void): void;
removeTypingStatusListener(callback: (users: string[]) => void): void;
addActionTriggeredListener(callback: (data: any) => void): void;
removeActionTriggeredListener(callback: (data: any) => void): void;
addUiInteractionListener(callback: (data: any) => void): void;
removeUiInteractionListener(callback: (data: any) => void): void;

login(userOrEmail: string, password: string, code?: string): Promise<any>;
logout(): Promise<void>;
autoLogin(auth: {
flow: "PASSWORD" | "OAUTH" | "TOKEN";
credentials: any;
}): Promise<void>;
googleSSOLogin(signIn: Function, acsCode: string): Promise<any>;

getRCAppInfo(): Promise<any>;
updateUserUsername(userid: string, username: string): Promise<any>;
channelInfo(): Promise<any>;
getRoomInfo(): Promise<any>;
permissionInfo(): Promise<any>;

setAuth(auth: RocketChatAuth): void;
getAuth(): RocketChatAuth;
getHost(): string;
}
Loading