Фикс двойного рукопожатия
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
|
||||
npm install # Установить зависимости
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
|
||||
deviceOs: systemInfo.os
|
||||
}
|
||||
protocol.connect();
|
||||
protocol.startHandshakeExchange(publicKey, privateKey, device);
|
||||
protocol.on('connect', () => {
|
||||
//protocol.startHandshakeExchange(publicKey, privateKey, device);
|
||||
protocol.once('connect', () => {
|
||||
protocol.startHandshakeExchange(publicKey, privateKey, device);
|
||||
/**
|
||||
* Сбрасываем подписки на онлайн статусы пользователей
|
||||
@@ -54,19 +54,19 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
|
||||
*/
|
||||
setOnlineSubscribes([]);
|
||||
});
|
||||
protocol.on('reconnect', () => {
|
||||
protocol.once('reconnect', () => {
|
||||
log("Connection lost, reconnecting and starting handshake exchange");
|
||||
setConnect(ProtocolState.RECONNECTING);
|
||||
});
|
||||
protocol.on('handshake_start', () => {
|
||||
protocol.once('handshake_start', () => {
|
||||
log("Handshake exchange started");
|
||||
setConnect(ProtocolState.HANDSHAKE_EXCHANGE);
|
||||
});
|
||||
protocol.on('handshake_complete', () => {
|
||||
protocol.once('handshake_complete', () => {
|
||||
log("Handshake exchange complete");
|
||||
setConnect(ProtocolState.CONNECTED);
|
||||
});
|
||||
protocol.on('handshake_need_device_verification', () => {
|
||||
protocol.once('handshake_need_device_verification', () => {
|
||||
log("Handshake exchange needs device verification");
|
||||
setConnect(ProtocolState.DEVICE_VERIFICATION_REQUIRED);
|
||||
navigate('/deviceconfirm');
|
||||
|
||||
Reference in New Issue
Block a user