Skip to content

Commit 6c15201

Browse files
committed
updates
1 parent 2a7685e commit 6c15201

File tree

17 files changed

+9688
-102
lines changed

17 files changed

+9688
-102
lines changed

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: npm run start:server-demo

apps/server-demo/src/main.ts

Lines changed: 200 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ app.post('/pusher/auth', function (req, res) {
2323
const auth = pusher.authenticate(socketId, channel, presenceData);
2424
res.send(auth);
2525
});
26-
const port = process.env.PORT || 5000;
26+
let port = Number(process.env.PORT || 5000);
2727
app.listen(port);
2828

29-
30-
31-
32-
const io = require("socket.io")(3000, {
29+
port++;
30+
const io = require("socket.io")(port, {
3331
path: "/",
3432
serveClient: true,
3533
pingInterval: 10000,
@@ -56,8 +54,8 @@ io.on('connection', function (socket) {
5654
addedUser = true;
5755
socket.username = data.username;
5856
console.log('Username: ', data.username);
59-
userList.push({ username: data.username });
60-
socket.emit('login', { userList: userList });
57+
userList.push({username: data.username});
58+
socket.emit('login', {userList: userList});
6159
socket.broadcast.emit('user joined', {
6260
username: data.username
6361
});
@@ -86,7 +84,7 @@ io.on('connection', function (socket) {
8684
console.log('User Disconnected')
8785
if (addedUser) {
8886
for (let i = 0; i < userList.length; i++) {
89-
if (socket.username === userList[ i ].username) {
87+
if (socket.username === userList[i].username) {
9088
userList.splice(i, 1)
9189
}
9290
}
@@ -113,3 +111,197 @@ nspChat.on('connect', (socket) => {
113111
})
114112
})
115113

114+
115+
/* WebRTC 1O1 */
116+
117+
port++;
118+
const wio = require("socket.io")(port, {
119+
path: "/",
120+
serveClient: true,
121+
pingInterval: 10000,
122+
pingTimeout: 5000,
123+
cookie: false
124+
});
125+
126+
const wMessageList = []
127+
let userMap = new Map();
128+
const lobby = 'lobby';
129+
130+
function getOtherUser(id) {
131+
const keys = Array.from(userMap.keys());
132+
const filtered = keys.filter((value) => {
133+
if (value.indexOf(id) === -1) {
134+
return value;
135+
}
136+
});
137+
return userMap.get(filtered[0]);
138+
}
139+
140+
wio.on('connection', function (socket) {
141+
socket.on('disconnect', function () {
142+
userMap.delete(socket.id);
143+
});
144+
userMap.set(socket.id, "");
145+
console.log('User Connected: -> ' + socket.id);
146+
socket.emit('connected', 'Welcome');
147+
148+
socket.on('init', function (data) {
149+
socket.join(data.id);
150+
userMap.set(socket.id, data.id);
151+
});
152+
153+
socket.on('call', function (data) {
154+
console.log('call from', data.from);
155+
const otherId = getOtherUser(socket.id);
156+
io.in(otherId).emit('call:incoming', {
157+
from: data.from,
158+
to: otherId,
159+
sdp: data.sdp
160+
});
161+
});
162+
163+
socket.on('iceCandidate', function (data) {
164+
console.log('call:iceCandidate', data.from);
165+
const otherId = getOtherUser(socket.id);
166+
io.in(otherId).emit('call:iceCandidate', Object.assign({}, data, {
167+
to: otherId
168+
}));
169+
});
170+
171+
socket.on('answer', function (data) {
172+
console.log('call:answer', data.from);
173+
const otherId = getOtherUser(socket.id);
174+
io.in(otherId).emit('call:answer', {
175+
from: data.from,
176+
sdp: data.sdp,
177+
to: otherId
178+
});
179+
});
180+
181+
socket.on('answered', function (data) {
182+
console.log('call:answered', data.from);
183+
const otherId = getOtherUser(socket.id);
184+
io.in(otherId).emit('call:answered', {
185+
from: data.from,
186+
sdp: data.sdp,
187+
to: otherId
188+
});
189+
})
190+
191+
});
192+
193+
194+
port++;
195+
const wio1 = require("socket.io")(port, {
196+
path: "/",
197+
serveClient: true,
198+
pingInterval: 10000,
199+
pingTimeout: 5000,
200+
cookie: false
201+
});
202+
203+
const wio1NspChat = wio1.of('/chat')
204+
const wio1NspDefault = wio1.of('/')
205+
206+
let wio1MessageList = []
207+
let wio1UserList = []
208+
209+
wio1.on('connection', function (socket) {
210+
console.log('User Connected');
211+
socket.emit('connected', 'Welcome');
212+
let addedUser = false;
213+
214+
socket.on('add user', function (data) {
215+
if (addedUser) return;
216+
addedUser = true;
217+
socket.username = data.username;
218+
console.log('Username: ', data.username);
219+
wio1UserList.push({
220+
username: data.username
221+
});
222+
223+
socket.emit('login', {
224+
userList: wio1UserList
225+
});
226+
227+
socket.broadcast.emit('user joined', {
228+
username: data.username
229+
});
230+
231+
socket.join(data.username);
232+
});
233+
234+
socket.on('call', function (data) {
235+
console.log('call from', data.from);
236+
console.log('call to', data.to);
237+
io.sockets.in(data.to).emit('call:incoming', data);
238+
});
239+
240+
241+
socket.on('iceCandidate', function (data) {
242+
io.sockets.in(data.to).emit('call:iceCandidate', data);
243+
});
244+
245+
socket.on('answer', function (data) {
246+
console.log('answer from', data.from);
247+
console.log('answer to', data.to);
248+
io.sockets.in(data.to).emit('call:answer', data);
249+
});
250+
251+
socket.on('answered', function (data) {
252+
console.log('answer from', data.from);
253+
console.log('answer to', data.to);
254+
io.sockets.in(data.to).emit('call:answered', data);
255+
})
256+
257+
socket.on('new message', function (data, cb) {
258+
cb(true);
259+
console.log(data);
260+
wio1MessageList.push(data);
261+
socket.broadcast.emit('new message', data);
262+
})
263+
264+
socket.on('getUsers', function () {
265+
socket.emit('getUsers', wio1UserList);
266+
})
267+
socket.on('user count', function () {
268+
socket.emit('user count', wio1UserList.length)
269+
})
270+
socket.on('getMessages', function () {
271+
socket.emit('getMessages', wio1MessageList)
272+
})
273+
274+
socket.on('disconnect', function () {
275+
console.log('User Disconnected');
276+
if (addedUser) {
277+
for (let i = 0; i < wio1UserList.length; i++) {
278+
if (socket.username === wio1UserList[i].username) {
279+
wio1UserList.splice(i, 1);
280+
}
281+
}
282+
socket.broadcast.emit('user left', {
283+
username: socket.username
284+
});
285+
286+
socket.emit('getUsers', wio1UserList);
287+
}
288+
})
289+
})
290+
291+
wio1NspDefault.on('connect', (socket) => {
292+
console.log('Joined Namespace: /')
293+
socket.on('disconnect', () => {
294+
console.log('Left Namespace: /')
295+
})
296+
})
297+
298+
wio1NspChat.on('connect', (socket) => {
299+
console.log('Joined Namespace: /chat')
300+
301+
socket.on('disconnect', () => {
302+
console.log('Left Namespace: /chat')
303+
})
304+
})
305+
306+
307+

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
"config": "nx g @nativescript/plugin-tools:config",
1111
"publish-packages": "nx g @nativescript/plugin-tools:publish",
1212
"docs:build": "cd docs && vuepress build src",
13-
"docs:dev": "cd docs && vuepress dev src"
13+
"docs:dev": "cd docs && vuepress dev src",
14+
"start:server-demo": "node dist/apps/server-demo/main"
1415
},
1516
"private": true,
1617
"dependencies": {
18+
"@types/node": "^15.3.0",
1719
"body-parser": "^1.19.0",
1820
"cors": "^2.8.5",
1921
"date-fns": "^2.21.3",
@@ -66,5 +68,8 @@
6668
"**/*": [
6769
"nx format:write --files"
6870
]
71+
},
72+
"engines" : {
73+
"node" : "14.x"
6974
}
7075
}
-4 Bytes
Binary file not shown.

packages/nativescript-couchbase/src-native/TNSCouchbase/.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/nativescript-couchbase/src-native/TNSCouchbase/.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/nativescript-couchbase/src-native/TNSCouchbase/.idea/runConfigurations.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.github.triniwiz.couchbase">
3-
4-
/
5-
</manifest>
3+
<uses-sdk android:minSdkVersion="22"/>
4+
</manifest>

packages/nativescript-image-cache-it/platforms/android/include.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repositories {
66

77
dependencies {
88
def kotlin_version = "1.4.21"
9-
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
9+
implementation 'com.squareup.okhttp3:okhttp:3.14.9'
1010
implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
1111
implementation 'jp.wasabeef:glide-transformations:4.1.0'
1212
implementation 'jp.co.cyberagent.android:gpuimage:2.0.3'

packages/nativescript-image-zoom/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Property, View} from "@nativescript/core";
1+
import {ImageAsset, ImageSource, Property, View} from "@nativescript/core";
22
import {Stretch} from "@nativescript/core/ui/image";
33

44
export class ImageZoomBase extends View {

0 commit comments

Comments
 (0)