Фикс двойного рукопожатия
This commit is contained in:
15
README.md
15
README.md
@@ -1,5 +1,20 @@
|
|||||||
# Сборка и установка
|
# Сборка и установка
|
||||||
|
|
||||||
|
### Создать app/servers.ts
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export const SERVERS = [
|
||||||
|
//'wss://cdn.rosetta-im.com', //main
|
||||||
|
//'ws://10.211.55.2:3000',
|
||||||
|
'ws://10.211.55.2:8881'
|
||||||
|
];
|
||||||
|
|
||||||
|
export function selectServer(): string {
|
||||||
|
const idx = Math.floor(Math.random() * SERVERS.length);
|
||||||
|
return SERVERS[idx];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install # Установить зависимости
|
npm install # Установить зависимости
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
|
|||||||
deviceOs: systemInfo.os
|
deviceOs: systemInfo.os
|
||||||
}
|
}
|
||||||
protocol.connect();
|
protocol.connect();
|
||||||
protocol.startHandshakeExchange(publicKey, privateKey, device);
|
//protocol.startHandshakeExchange(publicKey, privateKey, device);
|
||||||
protocol.on('connect', () => {
|
protocol.once('connect', () => {
|
||||||
protocol.startHandshakeExchange(publicKey, privateKey, device);
|
protocol.startHandshakeExchange(publicKey, privateKey, device);
|
||||||
/**
|
/**
|
||||||
* Сбрасываем подписки на онлайн статусы пользователей
|
* Сбрасываем подписки на онлайн статусы пользователей
|
||||||
@@ -54,19 +54,19 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
|
|||||||
*/
|
*/
|
||||||
setOnlineSubscribes([]);
|
setOnlineSubscribes([]);
|
||||||
});
|
});
|
||||||
protocol.on('reconnect', () => {
|
protocol.once('reconnect', () => {
|
||||||
log("Connection lost, reconnecting and starting handshake exchange");
|
log("Connection lost, reconnecting and starting handshake exchange");
|
||||||
setConnect(ProtocolState.RECONNECTING);
|
setConnect(ProtocolState.RECONNECTING);
|
||||||
});
|
});
|
||||||
protocol.on('handshake_start', () => {
|
protocol.once('handshake_start', () => {
|
||||||
log("Handshake exchange started");
|
log("Handshake exchange started");
|
||||||
setConnect(ProtocolState.HANDSHAKE_EXCHANGE);
|
setConnect(ProtocolState.HANDSHAKE_EXCHANGE);
|
||||||
});
|
});
|
||||||
protocol.on('handshake_complete', () => {
|
protocol.once('handshake_complete', () => {
|
||||||
log("Handshake exchange complete");
|
log("Handshake exchange complete");
|
||||||
setConnect(ProtocolState.CONNECTED);
|
setConnect(ProtocolState.CONNECTED);
|
||||||
});
|
});
|
||||||
protocol.on('handshake_need_device_verification', () => {
|
protocol.once('handshake_need_device_verification', () => {
|
||||||
log("Handshake exchange needs device verification");
|
log("Handshake exchange needs device verification");
|
||||||
setConnect(ProtocolState.DEVICE_VERIFICATION_REQUIRED);
|
setConnect(ProtocolState.DEVICE_VERIFICATION_REQUIRED);
|
||||||
navigate('/deviceconfirm');
|
navigate('/deviceconfirm');
|
||||||
|
|||||||
Reference in New Issue
Block a user