Skip to content

Commit 99ece1e

Browse files
chore(release): 5.1.0 [skip ci]
# [5.1.0](v5.0.0...v5.1.0) (2021-03-06) ### Features * Export Server class ([#101](#101)) ([a1e983b](a1e983b))
1 parent a1e983b commit 99ece1e

File tree

6 files changed

+122
-20
lines changed

6 files changed

+122
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [5.1.0](https://github.com/Rapsssito/react-native-tcp-socket/compare/v5.0.0...v5.1.0) (2021-03-06)
2+
3+
4+
### Features
5+
6+
* Export Server class ([#101](https://github.com/Rapsssito/react-native-tcp-socket/issues/101)) ([a1e983b](https://github.com/Rapsssito/react-native-tcp-socket/commit/a1e983b62bdc9f1320809cfda623609a9cb8a8ec))
7+
18
# [5.0.0](https://github.com/Rapsssito/react-native-tcp-socket/compare/v4.5.7...v5.0.0) (2021-02-26)
29

310

coverage/coverage-final.json

Lines changed: 3 additions & 2 deletions
Large diffs are not rendered by default.

lib/types/Globals.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const nativeEventEmitter: import("react-native").EventEmitter;
2+
export function getInstanceNumber(): number;

lib/types/Server.d.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* @extends {EventEmitter<'connection' | 'listening' | 'error' | 'close', any>}
3+
*/
4+
export default class Server extends EventEmitter<"error" | "close" | "connection" | "listening", any> {
5+
/**
6+
* @param {(socket: TcpSocket) => void} [connectionCallback] Automatically set as a listener for the `'connection'` event.
7+
*/
8+
constructor(connectionCallback?: ((socket: TcpSocket) => void) | undefined);
9+
/** @private */
10+
private _id;
11+
/** @private */
12+
private _eventEmitter;
13+
/** @private @type {TcpSocket[]} */
14+
private _connections;
15+
/** @private */
16+
private _localAddress;
17+
/** @private */
18+
private _localPort;
19+
/** @private */
20+
private _localFamily;
21+
listening: boolean;
22+
/**
23+
* Start a server listening for connections.
24+
*
25+
* This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted.
26+
* The last parameter `callback` will be added as a listener for the `'listening'` event.
27+
*
28+
* The `server.listen()` method can be called again if and only if there was an error during the first
29+
* `server.listen()` call or `server.close()` has been called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN`
30+
* error will be thrown.
31+
*
32+
* @param {{ port: number; host: string; reuseAddress?: boolean}} options
33+
* @param {() => void} [callback]
34+
* @returns {Server}
35+
*/
36+
listen(options: {
37+
port: number;
38+
host: string;
39+
reuseAddress?: boolean;
40+
}, callback?: (() => void) | undefined): Server;
41+
/**
42+
* Asynchronously get the number of concurrent connections on the server.
43+
*
44+
* Callback should take two arguments `err` and `count`.
45+
*
46+
* @param {(err: Error | null, count: number) => void} callback
47+
* @returns {Server}
48+
*/
49+
getConnections(callback: (err: Error | null, count: number) => void): Server;
50+
/**
51+
* Stops the server from accepting new connections and keeps existing connections.
52+
* This function is asynchronous, the server is finally closed when all connections are ended and the server emits a `'close'` event.
53+
* The optional callback will be called once the `'close'` event occurs. Unlike that event, it will be called with an `Error` as its
54+
* only argument if the server was not open when it was closed.
55+
*
56+
* @param {(err?: Error) => void} [callback] Called when the server is closed.
57+
* @returns {Server}
58+
*/
59+
close(callback?: ((err?: Error | undefined) => void) | undefined): Server;
60+
/**
61+
* Returns the bound `address`, the address `family` name, and `port` of the server as reported by the operating system if listening
62+
* on an IP socket (useful to find which port was assigned when getting an OS-assigned address):
63+
* `{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
64+
*
65+
* @returns {import('./TcpSocket').AddressInfo | null}
66+
*/
67+
address(): import('./TcpSocket').AddressInfo | null;
68+
ref(): Server;
69+
unref(): Server;
70+
/**
71+
* @private
72+
*/
73+
private _registerEvents;
74+
_errorListener: import("react-native").EmitterSubscription | undefined;
75+
_closeListener: import("react-native").EmitterSubscription | undefined;
76+
_connectionsListener: import("react-native").EmitterSubscription | undefined;
77+
/**
78+
* @private
79+
*/
80+
private _unregisterEvents;
81+
/**
82+
* @private
83+
*/
84+
private _setDisconnected;
85+
/**
86+
* @private
87+
* @param {{ id: number; connection: import('./TcpSocket').NativeConnectionInfo; }} info
88+
*/
89+
private _buildSocket;
90+
}
91+
import EventEmitter from "eventemitter3";
92+
import TcpSocket from "./TcpSocket";

lib/types/index.d.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
export default tcpSockets;
2-
declare const tcpSockets: TCPSockets;
3-
declare class TCPSockets {
4-
instances: number;
5-
_eventEmitter: import("react-native").EventEmitter;
6-
/**
7-
* @param {(socket: Socket) => void} connectionListener
8-
* @returns {Server}
9-
*/
10-
createServer(connectionListener: (socket: Socket) => void): Server;
11-
/**
12-
* @param {import('./TcpSocket').ConnectionOptions} options
13-
* @param {() => void} callback
14-
* @returns {Socket}
15-
*/
16-
createConnection(options: import('./TcpSocket').ConnectionOptions, callback: () => void): Socket;
1+
declare namespace _default {
2+
export { createServer };
3+
export { createConnection };
4+
export { Server };
175
}
6+
export default _default;
7+
/**
8+
* @param {(socket: Socket) => void} connectionListener
9+
* @returns {Server}
10+
*/
11+
declare function createServer(connectionListener: (socket: Socket) => void): Server;
12+
/**
13+
* @param {import('./TcpSocket').ConnectionOptions} options
14+
* @param {() => void} callback
15+
* @returns {Socket}
16+
*/
17+
declare function createConnection(options: import('./TcpSocket').ConnectionOptions, callback: () => void): Socket;
18+
import Server from "./Server";
1819
import Socket from "./TcpSocket";
19-
import Server from "./TcpServer";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-tcp-socket",
33
"title": "React Native Tcp Socket",
4-
"version": "5.0.0",
4+
"version": "5.1.0",
55
"description": "React Native TCP socket API for Android & iOS with SSL/TLS support",
66
"main": "src/index.js",
77
"types": "lib/types/index.d.ts",

0 commit comments

Comments
 (0)