Ajoue du serveur et du client qui marche
continuous-integration/drone/push Build is failing Details

Persistance
Thomas Chazot 2 years ago
parent 6b7c2eff3b
commit 0bd40cdd95

@ -7,8 +7,10 @@ import { useFonts } from 'expo-font';
export default function App() { export default function App() {
const [fontsLoaded] = useFonts({ const [fontsLoaded] = useFonts({
'Helvetica': require('./assets/fonts/Helvetica.ttf'), 'Helvetica': require('./assets/fonts/Helvetica.ttf'),
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

@ -1,40 +0,0 @@
const express = require("express");
const app = express();
const PORT = 4000;
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
const http = require("http").Server(app);
const cors = require("cors");
const socketIO = require('socket.io')(http, {
cors: {
origin: "<http://localhost:3000>"
}
});
//👇🏻 Add this before the app.get() block
socketIO.on('connection', (socket) => {
console.log(`⚡: ${socket.id} user just connected!`);
socket.on("singIn", (test) => {
console.log(test);
});
socket.on('disconnect', () => {
socket.disconnect()
console.log('🔥: A user disconnected');
});
});
app.get("/api", (req, res) => {
res.json({
message: "Hello world",
});
});
app.listen(PORT, () => {
console.log(`Server listening on ${PORT}`);
});

@ -0,0 +1,8 @@
const { io } = require("socket.io-client");
export default socket = io("http://localhost:3000");

@ -0,0 +1,22 @@
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
const connectUsers = []
io.on('connection', (socket) => {
console.log(socket.id)
socket.on('joinRoom', ({username}) => {
connectUsers.push(username)
socket.emit('roomJoined', connectUsers)
});
});
server.listen(3000, () => {
console.log('listening on *:3000');
});

@ -8,6 +8,7 @@ import {
Image, Image,
TouchableHighlight, TouchableHighlight,
Alert, Alert,
ImageBackground,
} from 'react-native' } from 'react-native'
import { MANAGER_MATCH, MANAGER_USER } from '../../../appManagers'; import { MANAGER_MATCH, MANAGER_USER } from '../../../appManagers';
import { useMatchStore } from '../../context/matchContext'; import { useMatchStore } from '../../context/matchContext';
@ -114,20 +115,21 @@ function CookieClicker(props: { navigation: any}){
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View > <ImageBackground source={{ uri: "https://i0.wp.com/lesfoliesdejenny.fr/wp-content/uploads/2021/12/5.png?w=1080&ssl=1" }} resizeMode="cover" style={styles.image}>
<Text> <View style={styles.containerTop}>
<Text style={styles.cout}>
Timer: {timer} Timer: {timer}
</Text> </Text>
<TouchableHighlight onPress={onPressCookie} > <TouchableHighlight onPress={onPressCookie} >
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png' }} /> <Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png' }} />
</TouchableHighlight> </TouchableHighlight>
<Text> <Text style={styles.cout}>
Argent {money} Argent {money}
</Text> </Text>
<Text> <Text style={styles.cout}>
Points {count} Points {count}
</Text> </Text>
</View>
<View style={styles.containerRight}> <View style={styles.containerRight}>
<TouchableHighlight onPress={onPressGrandma}> <TouchableHighlight onPress={onPressGrandma}>
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png' }} /> <Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png' }} />
@ -173,14 +175,19 @@ function CookieClicker(props: { navigation: any}){
Cost {portalCost} Cost {portalCost}
</Text> </Text>
</View> </View>
</View>
</View> </View>
</ImageBackground>
</View> </View>
) )
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1,
},
containerTop:{
top: 75, top: 75,
margin: 10, margin: 10,
flex: 1, flex: 1,
@ -190,7 +197,6 @@ const styles = StyleSheet.create({
containerRight: { containerRight: {
flex: 1, flex: 1,
flexWrap: "wrap", flexWrap: "wrap",
top: 100,
marginBottom: 20, marginBottom: 20,
left: 100, left: 100,
}, },
@ -208,12 +214,18 @@ const styles = StyleSheet.create({
marginBottom: 10 marginBottom: 10
}, },
photo: { photo: {
width: 50, width: 75,
height: 100 height: 75
}, },
cout: { cout: {
marginBottom: 20 marginBottom: 20,
} color: "white",
fontSize: 15
},
image: {
flex: 1,
justifyContent: "center"
},
}) })

Loading…
Cancel
Save