added simple websocket connection

This commit is contained in:
Niklas 2021-01-23 01:43:25 +01:00
parent 35b7a51ede
commit 66ae1bd758

View File

@ -7,18 +7,24 @@ import {
View, View,
} from 'react-native'; } from 'react-native';
const ws = new WebSocket('ws://192.168.1.109:8069/ws');
interface Props { interface Props {
text: string; text: string;
} }
export default function DeckButton(props: Props) { export default function DeckButton(props: Props) {
function pressed() {
ws.send(props.text);
}
return ( return (
<> <>
<View style={style.view}> <View style={style.view}>
<TouchableHighlight <TouchableHighlight
style={style.touchable} style={style.touchable}
underlayColor={'#0e86d4'} underlayColor={'#0e86d4'}
onPress={() => console.log(props.text)} onPress={pressed}
onLongPress={() => console.log('long press')}> onLongPress={() => console.log('long press')}>
<Text style={style.text}>{props.text}</Text> <Text style={style.text}>{props.text}</Text>
</TouchableHighlight> </TouchableHighlight>