https://github.com/bibhuti9/socketio-in-react-native
https://github.com/bibhuti9/socketio-in-react-native
Last synced: about 13 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/bibhuti9/socketio-in-react-native
- Owner: bibhuti9
- Created: 2022-07-16T11:19:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-29T19:38:26.000Z (almost 3 years ago)
- Last Synced: 2025-03-22T21:34:00.644Z (7 months ago)
- Language: Java
- Size: 415 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
"# SocketIO-in-react-native"
// Turn on the connection and then set the emiter name as on()
Here the request package used for call the API like Fetch
the socket.send is used for send the data to the client
and the msg which is revived from the client side.io.on("connection", (socket) => {
socket.on("message", (msg) => {
request.post(
{
url: `${process.env.BACKEND_URI}/restuarent/fetchAllCategory`,
formData: "demo",
},
function optionalCallback(err, body) {
if (err) {
return console.error("upload failed:", err);
}
socket.send(JSON.parse(body.body));
}
);
});
});/* Client */
socketRef.current = io(BACKEND_URI);
socketRef.current.on('message', msg => {
setItem(msg.Data);
});
socketRef.current.emit('message', userUID);