-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
index.d.ts
89 lines (80 loc) · 3.62 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import type { EmitterSubscription } from 'react-native'
export interface Device {
deviceAddress: string
deviceName: string
isGroupOwner: boolean
primaryDeviceType: string | null
secondaryDeviceType: string | null
status: number
}
export interface ConnectionArgs {
deviceAddress: string
groupOwnerIntent?: number
}
export interface GroupInfo {
interface: string
networkName: string
passphrase: string
owner: {
deviceAddress: string
deviceName: string
primaryDeviceType: string | null
secondaryDeviceType: string | null
status: number
}
}
export interface WifiP2pInfo {
groupOwnerAddress: {
hostAddress: string
isLoopbackAddress: boolean
} | null
groupFormed: boolean
isGroupOwner: boolean
}
export const PEERS_UPDATED_ACTION: string
export const CONNECTION_INFO_UPDATED_ACTION: string
export const THIS_DEVICE_CHANGED_ACTION: string
// public methods
export const initialize: () => Promise<boolean>
export const startDiscoveringPeers: () => Promise<string>
export const stopDiscoveringPeers: () => Promise<void>
export const subscribeOnThisDeviceChanged: (callback: (data: GroupInfo) => void) => EmitterSubscription
/**
* @deprecated since RN 0.65 because of favour to new API.
* @see https://github.com/kirillzyusko/react-native-wifi-p2p/releases/tag/3.3.0 for migration process.
*/
export const unsubscribeFromThisDeviceChanged: (callback: (data: GroupInfo) => void) => void
export const subscribeOnPeersUpdates: (callback: (data: {devices: Device[]}) => void) => EmitterSubscription
/**
* @deprecated since RN 0.65 because of favour to new API.
* @see https://github.com/kirillzyusko/react-native-wifi-p2p/releases/tag/3.3.0 for migration process.
*/
export const unsubscribeFromPeersUpdates: (callback: (data: {devices: Device[]}) => void) => void
export const subscribeOnConnectionInfoUpdates: (callback: (data: WifiP2pInfo) => void) => EmitterSubscription
/**
* @deprecated since RN 0.65 because of favour to new API.
* @see https://github.com/kirillzyusko/react-native-wifi-p2p/releases/tag/3.3.0 for migration process.
*/
export const unsubscribeFromConnectionInfoUpdates: (callback: (data: WifiP2pInfo) => void) => void
export const getAvailablePeers: () => Promise<{devices: Device[]}>
export const connect: (deviceAddress: string) => Promise<void>
export const connectWithConfig: (config: ConnectionArgs) => Promise<void>
export const cancelConnect: () => Promise<void>
export const createGroup: () => Promise<void>
export const removeGroup: () => Promise<void>
export const getConnectionInfo: () => Promise<WifiP2pInfo>
export const getGroupInfo: () => Promise<GroupInfo>
export const sendFile: (pathToFile: string) => Promise<{ time: number, file: string }>
export const sendFileTo: (pathToFile: string, address: string) => Promise<{ time: number, file: string }>
export const receiveFile: (folder: string, fileName: string, forceToScanGallery?: boolean) => Promise<string>
export const sendMessage: (message: string) => Promise<{ time: number, message: string }>
export const sendMessageTo: (message: string, address: string) => Promise<{ time: number, message: string }>
export const receiveMessage: (props: { meta: boolean }) => Promise<string>
export const stopReceivingMessage: () => void
// system methods
export const subscribeOnEvent: (event: string, callback: Function) => EmitterSubscription
/**
* @deprecated since RN 0.65 because of favour to new API.
* @see https://github.com/kirillzyusko/react-native-wifi-p2p/releases/tag/3.3.0 for migration process.
*/
export const unsubscribeFromEvent: (event: string, callback: Function) => void