Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 5d1cbd7

Browse files
committed
upgrade dependencies, preapre for migration to plugin seed
1 parent 11d609a commit 5d1cbd7

File tree

16 files changed

+168
-154
lines changed

16 files changed

+168
-154
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ demo/node_modules
88
*.map
99
*.d.ts
1010
!references.d.ts
11-
!common.d.ts
1211
!helpers.d.ts
13-
!socket.d.ts
12+
!socketio.common.d.ts
13+
!index.d.ts
1414
!typings/*
1515
typings-*
1616
out

.npmignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
demo/
22
demo.server/
3+
*.map
34
*.ts
4-
!common.d.ts
5+
!socketio.common.d.ts
56
!helpers.d.ts
6-
!socket.d.ts
7-
*.map
7+
!index.d.ts
88
*.json
99
*.log
1010
.tmp

README.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,62 @@
11
nativescript-socket.io
22
======================
33

4-
Socket.io implementation in NativeScript.
4+
Socket.IO fully-featured and compliant client implementation for NativeScript.
55

6-
# State
6+
# Status
77

8-
Android and iOS implementations are stable and in sync.
8+
![Status](https://img.shields.io/badge/status-production--ready-green.svg)
9+
[![npm](https://img.shields.io/npm/l/nativescript-socket.io.svg?maxAge=1000)](https://github.com/naderio/nativescript-socket.io/blob/master/LICENSE.md)
10+
[![npm](https://img.shields.io/npm/v/nativescript-socket.io.svg?maxAge=1000)](https://www.npmjs.com/package/nativescript-socket.io)
11+
[![dependency Status](https://img.shields.io/david/naderio/nativescript-socket.io.svg?maxAge=1000)](https://david-dm.org/naderio/nativescript-socket.io)
12+
[![devDependency Status](https://img.shields.io/david/dev/naderio/nativescript-socket.io.svg?maxAge=1000)](https://david-dm.org/naderio/nativescript-socket.io)
13+
[![devDependency Status](https://img.shields.io/david/peer/naderio/nativescript-socket.io.svg?maxAge=1000)](https://david-dm.org/naderio/nativescript-socket.io)
14+
[![Build Status](https://travis-ci.org/naderio/nativescript-socket.io.svg?branch=master)](https://travis-ci.org/naderio/nativescript-socket.io)
15+
[![npm](https://img.shields.io/npm/dt/nativescript-socket.io.svg?maxAge=1000)](https://www.npmjs.com/package/nativescript-socket.io)
16+
17+
This library is production-ready. Both Android and iOS implementations are stable and in sync.
918

1019
Please check [releases and changelog](https://github.com/naderio/nativescript-socket.io/releases) and [roadmap](https://github.com/naderio/nativescript-socket.io/issues/3) for more information.
1120

1221
# Dependencies
1322

1423
Android: [Socket.IO-client Java](https://github.com/socketio/socket.io-client-java) v1.*
1524

16-
iOS: [Socket.IO-Client-Swift](https://github.com/socketio/socket.io-client-swift) v11.*
25+
iOS: [Socket.IO-Client-Swift](https://github.com/socketio/socket.io-client-swift) v12.*
1726

1827
# Install
1928

20-
```
29+
```sh
2130
tns plugin add nativescript-socket.io
2231
```
2332

2433
# Usage
2534

26-
```
27-
var SocketIO = require('nativescript-socket.io');
35+
```javascript
36+
const SocketIO = require('nativescript-socket.io');
2837

2938
SocketIO.enableDebug(); // optionnal
3039

3140
// or use your own debug function
3241
// SocketIO.enableDebug(myCustomDebugFunction);
3342

34-
var options = {
43+
const options = {
3544
query: {
3645
token: 'SOME_TOKEN_HERE',
3746
},
3847
};
3948

40-
var socket = SocketIO.connect('http://somewhere/namespace', options);
49+
const socketio = SocketIO.connect('http://somewhere/namespace', options);
4150

42-
socket.on('connect', function(){
51+
socketio.on('connect', function(){
4352
console.log('connect');
4453
});
4554

46-
socket.on('hello', function(){
55+
socketio.on('hello', function(){
4756
console.log('hello', arguments);
4857
});
4958

50-
socket.on('request', function(info, ack){
59+
socketio.on('request', function(info, ack){
5160
console.log('request', info);
5261
if (info === 'datetime') {
5362
ack(new Date());
@@ -58,11 +67,11 @@ socket.on('request', function(info, ack){
5867
}
5968
});
6069

61-
socket.emit('hello', {
70+
socketio.emit('hello', {
6271
username: 'someone',
6372
});
6473

65-
socket.emit('hello-ack', {
74+
socketio.emit('hello-ack', {
6675
username: 'someone',
6776
}, function ack(){
6877
console.log('hello-ack', arguments);
@@ -72,23 +81,28 @@ socket.emit('hello-ack', {
7281

7382
## Usage with TypeScript
7483

75-
import using either of
84+
import using either of the following:
85+
86+
```typescript
87+
import * as SocketIO from "nativescript-socket.io"`
7688
77-
* `import * as SocketIO from "nativescript-socket.io"`
78-
* `var SocketIO = require("nativescript-socket.io")`
89+
// OR
90+
91+
const SocketIO = require("nativescript-socket.io")
92+
```
7993

8094
# Demo
8195

8296
first start the socket.io demo server
8397

84-
```
98+
```sh
8599
cd ./demo/server
86100
npm start
87101
```
88102

89103
then build and run the app
90104

91-
```
105+
```sh
92106
cd ./demo
93107
tns run android
94108
```

demo.server/index.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// this is a test server to support tests which make requests
22

3-
var io = require('socket.io');
4-
var server = io(process.env.ZUUL_PORT || 3210, { pingInterval: 2000 });
3+
var socketio = require('socket.io');
4+
var server = socketio(process.env.ZUUL_PORT || 3210, { pingInterval: 2000 });
55
var expect = require('expect.js');
66

77
var debug = require('./debug')('socket.io');
@@ -22,126 +22,126 @@ server.of('/asd').on('connection', function() {
2222
// register namespace
2323
});
2424

25-
server.of('/demo').on('connection', function(socket) {
25+
server.of('/demo').on('connection', function(soc) {
2626
debug('connect');
2727

28-
// debug('socket.handshake', socket.handshake);
28+
// debug('soc.handshake', soc.handshake);
2929

30-
debug('socket.request._query', socket.request._query);
30+
debug('soc.request._query', soc.request._query);
3131

3232
// simple test
33-
socket.on('hi', function() {
33+
soc.on('hi', function() {
3434
args = Array.prototype.slice.call(arguments);
3535
debug('on', 'hi', JSON.stringify(Array.from(arguments), null, 2));
3636
args.unshift('hi');
37-
socket.emit.apply(socket, args);
37+
soc.emit.apply(soc, args);
3838
});
3939

4040
// ack tests
41-
socket.on('ack', function() {
41+
soc.on('ack', function() {
4242
debug('on', 'ack', JSON.stringify(Array.from(arguments), null, 2));
43-
socket.emit('ack', function(a, b) {
43+
soc.emit('ack', function(a, b) {
4444
debug('on', 'ack', 'ack', JSON.stringify(Array.from(arguments), null, 2));
4545
if (a === 5 && b.test) {
46-
socket.emit('got it');
46+
soc.emit('got it');
4747
}
4848
});
4949
});
5050

51-
socket.on('getAckDate', function(data, cb) {
51+
soc.on('getAckDate', function(data, cb) {
5252
debug('on', 'getAckDate', JSON.stringify(Array.from(arguments), null, 2));
5353
cb(new Date('2017-01-01'));
5454
});
5555

56-
socket.on('getDate', function() {
56+
soc.on('getDate', function() {
5757
debug('on', 'getDate', JSON.stringify(Array.from(arguments), null, 2));
58-
socket.emit('takeDate', new Date('2017-01-01'));
58+
soc.emit('takeDate', new Date('2017-01-01'));
5959
});
6060

61-
socket.on('getDateObj', function() {
61+
soc.on('getDateObj', function() {
6262
debug('on', 'getDateObj', JSON.stringify(Array.from(arguments), null, 2));
63-
socket.emit('takeDateObj', { date: new Date('2017-01-01') });
63+
soc.emit('takeDateObj', { date: new Date('2017-01-01') });
6464
});
6565

66-
socket.on('getUtf8', function() {
66+
soc.on('getUtf8', function() {
6767
debug('on', 'getUtf8', JSON.stringify(Array.from(arguments), null, 2));
68-
socket.emit('takeUtf8', 'てすと');
69-
socket.emit('takeUtf8', 'Я Б Г Д Ж Й');
70-
socket.emit('takeUtf8', 'Ä ä Ü ü ß');
71-
socket.emit('takeUtf8', 'utf8 — string');
72-
socket.emit('takeUtf8', 'utf8 — string');
68+
soc.emit('takeUtf8', 'てすと');
69+
soc.emit('takeUtf8', 'Я Б Г Д Ж Й');
70+
soc.emit('takeUtf8', 'Ä ä Ü ü ß');
71+
soc.emit('takeUtf8', 'utf8 — string');
72+
soc.emit('takeUtf8', 'utf8 — string');
7373
});
7474

7575
// false test
76-
socket.on('false', function() {
77-
socket.emit('false', false);
76+
soc.on('false', function() {
77+
soc.emit('false', false);
7878
});
7979

8080
// binary test
81-
socket.on('doge', function() {
81+
soc.on('doge', function() {
8282
var buf = new Buffer('asdfasdf', 'utf8');
83-
socket.emit('doge', buf);
83+
soc.emit('doge', buf);
8484
});
8585

8686
// expect receiving binary to be buffer
87-
socket.on('buffa', function(a) {
88-
if (Buffer.isBuffer(a)) socket.emit('buffack');
87+
soc.on('buffa', function(a) {
88+
if (Buffer.isBuffer(a)) soc.emit('buffack');
8989
});
9090

9191
// expect receiving binary with mixed JSON
92-
socket.on('jsonbuff', function(a) {
92+
soc.on('jsonbuff', function(a) {
9393
expect(a.hello).to.eql('lol');
9494
expect(Buffer.isBuffer(a.message)).to.be(true);
9595
expect(a.goodbye).to.eql('gotcha');
96-
socket.emit('jsonbuff-ack');
96+
soc.emit('jsonbuff-ack');
9797
});
9898

9999
// expect receiving buffers in order
100100
var receivedAbuff1 = false;
101-
socket.on('abuff1', function(a) {
101+
soc.on('abuff1', function(a) {
102102
expect(Buffer.isBuffer(a)).to.be(true);
103103
receivedAbuff1 = true;
104104
});
105-
socket.on('abuff2', function(a) {
105+
soc.on('abuff2', function(a) {
106106
expect(receivedAbuff1).to.be(true);
107-
socket.emit('abuff2-ack');
107+
soc.emit('abuff2-ack');
108108
});
109109

110110
// expect sent blob to be buffer
111-
socket.on('blob', function(a) {
112-
if (Buffer.isBuffer(a)) socket.emit('back');
111+
soc.on('blob', function(a) {
112+
if (Buffer.isBuffer(a)) soc.emit('back');
113113
});
114114

115115
// expect sent blob mixed with json to be buffer
116-
socket.on('jsonblob', function(a) {
116+
soc.on('jsonblob', function(a) {
117117
expect(a.hello).to.eql('lol');
118118
expect(Buffer.isBuffer(a.message)).to.be(true);
119119
expect(a.goodbye).to.eql('gotcha');
120-
socket.emit('jsonblob-ack');
120+
soc.emit('jsonblob-ack');
121121
});
122122

123123
// expect blobs sent in order to arrive in correct order
124124
var receivedblob1 = false;
125125
var receivedblob2 = false;
126-
socket.on('blob1', function(a) {
126+
soc.on('blob1', function(a) {
127127
expect(Buffer.isBuffer(a)).to.be(true);
128128
receivedblob1 = true;
129129
});
130-
socket.on('blob2', function(a) {
130+
soc.on('blob2', function(a) {
131131
expect(receivedblob1).to.be(true);
132132
expect(a).to.eql('second');
133133
receivedblob2 = true;
134134
});
135-
socket.on('blob3', function(a) {
135+
soc.on('blob3', function(a) {
136136
expect(Buffer.isBuffer(a)).to.be(true);
137137
expect(receivedblob1).to.be(true);
138138
expect(receivedblob2).to.be(true);
139-
socket.emit('blob3-ack');
139+
soc.emit('blob3-ack');
140140
});
141141

142142
// emit buffer to base64 receiving browsers
143-
socket.on('getbin', function() {
143+
soc.on('getbin', function() {
144144
var buf = new Buffer('asdfasdf', 'utf8');
145-
socket.emit('takebin', buf);
145+
soc.emit('takebin', buf);
146146
});
147147
});

demo.server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"license": "ISC",
1010
"dependencies": {
1111
"expect.js": "^0.3.1",
12-
"socket.io": "^2.0.3"
12+
"socket.io": "^2.0.4"
1313
}
1414
}

demo/app/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as SocketIO from 'nativescript-socket.io';
44
// import * as SocketIO from './dev';
55

6-
export var socket = SocketIO.connect('http://192.168.1.111:3210/demo', <SocketIO.SocketOptions>{
6+
export var socketio = SocketIO.connect('http://192.168.1.111:3210/demo', <SocketIO.SocketOptions>{
77
// log: true,
88
// secure: false,
99
// forceWebsockets: true,

0 commit comments

Comments
 (0)