Skip to content

Commit 24207eb

Browse files
author
android-js
authored
Merge pull request #1 from DeveshPankaj/master
Sample chat-app included .
2 parents 5b421b4 + c156391 commit 24207eb

File tree

981 files changed

+116673
-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.

981 files changed

+116673
-0
lines changed

chat-app/.DS_Store

6 KB
Binary file not shown.

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/.DS_Store

6 KB
Binary file not shown.

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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
var tunnel = localtunnel(3001, function(err, tunnel) {
10+
if (err) throw err;
11+
console.log(tunnel.url);
12+
ip = tunnel.url;
13+
});
14+
15+
tunnel.on('close', function() {
16+
console.log('tunnel, closed');
17+
});
18+
19+
20+
21+
http.listen(3001);
22+
23+
24+
let ip = undefined;
25+
ip = ip_npm.address();
26+
// (async () => {
27+
// ip = await publicIp.v4();
28+
// })();
29+
30+
// MY CHAT APP
31+
back.on('get-ip', function () {
32+
console.log('ip request');
33+
return ip;
34+
});
35+
36+
37+
io.on('connection', function (socket) {
38+
console.log('a user2 connected');
39+
40+
socket.emit('hide-modal');
41+
front.send('hide-modal');
42+
43+
socket.on('msg', (text) => {
44+
console.log('msg from second user', text);
45+
back.send('msg', text);
46+
});
47+
48+
back.on('msg', (text)=>{
49+
socket.emit('msg', text);
50+
});
51+
52+
socket.on('disconnect', function () {
53+
console.log('user2 disconnected');
54+
front.send('open-modal');
55+
});
56+
});

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)