Skip to content

Commit 7cfe634

Browse files
committed
Added: chat app
1 parent 6f9c104 commit 7cfe634

File tree

983 files changed

+116699
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

983 files changed

+116699
-0
lines changed

chat app/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
## Build
3+
```bash
4+
$ androidjs b
5+
```
6+

chat app/assets/icon/app3.png

5 KB
Loading
27.5 KB
Loading
9.27 KB
Loading

chat app/assets/icon/icon.png

25.7 KB
Loading

chat app/assets/ipc/front.js

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chat app/main.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const {back} = require('androidjs');
2+
const http = require('http').createServer();
3+
const io = require("socket.io")(http);
4+
const publicIp = require('public-ip');
5+
const ip_npm = require('ip');
6+
7+
var localtunnel = require('localtunnel');
8+
9+
10+
http.listen(3001);
11+
12+
13+
let ip = undefined;
14+
//ip = ip_npm.address();
15+
// (async () => {
16+
// ip = await publicIp.v4();
17+
// })();
18+
19+
var tunnel = localtunnel(3001, function(err, tunnel) {
20+
if (err) throw err;
21+
console.log(tunnel.url);
22+
ip = tunnel.url;
23+
});
24+
25+
tunnel.on('close', function() {
26+
console.log('tunnel, closed');
27+
});
28+
29+
30+
31+
// MY CHAT APP
32+
back.on('get-ip', function () {
33+
setTimeout(()=>{
34+
if(ip !== undefined){
35+
back.send('ip', ip);
36+
}else{
37+
back.send('ip', "Failed: to get url");
38+
}
39+
}, 4000);
40+
});
41+
42+
43+
io.on('connection', function (socket) {
44+
console.log('a user2 connected');
45+
46+
socket.emit('hide-modal');
47+
front.send('hide-modal');
48+
49+
socket.on('msg', (text) => {
50+
console.log('msg from second user', text);
51+
back.send('msg', text);
52+
});
53+
54+
back.on('msg', (text)=>{
55+
socket.emit('msg', text);
56+
});
57+
58+
socket.on('disconnect', function () {
59+
console.log('user2 disconnected');
60+
front.send('open-modal');
61+
});
62+
});

chat app/node_modules/@sindresorhus/is/dist/index.d.ts

Lines changed: 132 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)