-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathMessageInput.tsx
More file actions
30 lines (24 loc) · 1.01 KB
/
Copy pathMessageInput.tsx
File metadata and controls
30 lines (24 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {Flex, Button, Input} from "@luxonis/common-fe-components";
import {useRef} from "react";
import {useDaiConnection} from "@luxonis/depthai-viewer-common";
export function MessageInput() {
const connection = useDaiConnection();
const inputRef = useRef<HTMLInputElement>(null);
const handleSendMessage = () => {
if (inputRef.current) {
const message = inputRef.current.value;
console.log('Sending message:', message);
// @ts-ignore - We're using an example service here which isn't part of the DAI services enum
connection.daiConnection?.postToService('Custom Service', message, (response) => {
console.log('Received response:', response);
});
inputRef.current.value = '';
}
}
return (
<Flex direction="row" gap="sm" alignItems="center">
<Input type="text" placeholder="Message" ref={inputRef} />
<Button onClick={handleSendMessage}>Send</Button>
</Flex>
);
}