Синхронизация и фикс двойного сокета
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ LICENSE
|
|||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
.env.production.local
|
.env.production.local
|
||||||
|
app/servers.ts
|
||||||
@@ -437,16 +437,17 @@ export function useDialogFiber() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fromPublicKey = packet.getFromPublicKey();
|
const fromPublicKey = packet.getFromPublicKey();
|
||||||
|
const toPublicKey = packet.getToPublicKey();
|
||||||
if(fromPublicKey != publicKey){
|
if(fromPublicKey != publicKey){
|
||||||
/**
|
/**
|
||||||
* Игнорируем если это не наше прочтение
|
* Игнорируем если это не синхронизация нашего прочтения
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const toPublicKey = packet.getToPublicKey();
|
|
||||||
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`,
|
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`,
|
||||||
[toPublicKey, fromPublicKey, publicKey]);
|
[fromPublicKey, toPublicKey, publicKey]);
|
||||||
|
|
||||||
|
console.info("updating with params ", [fromPublicKey, toPublicKey, publicKey]);
|
||||||
updateDialog(toPublicKey);
|
updateDialog(toPublicKey);
|
||||||
log("Read sync packet from other device");
|
log("Read sync packet from other device");
|
||||||
addOrUpdateDialogCache(fromPublicKey, getDialogCache(fromPublicKey).map((message) => {
|
addOrUpdateDialogCache(fromPublicKey, getDialogCache(fromPublicKey).map((message) => {
|
||||||
@@ -460,7 +461,7 @@ export function useDialogFiber() {
|
|||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}));
|
}));
|
||||||
}, [updateDialog]);
|
}, [updateDialog, publicKey]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Обработчик прочтения личных сообщений
|
* Обработчик прочтения личных сообщений
|
||||||
@@ -475,6 +476,13 @@ export function useDialogFiber() {
|
|||||||
}
|
}
|
||||||
const fromPublicKey = packet.getFromPublicKey();
|
const fromPublicKey = packet.getFromPublicKey();
|
||||||
const toPublicKey = packet.getToPublicKey();
|
const toPublicKey = packet.getToPublicKey();
|
||||||
|
if(fromPublicKey == publicKey){
|
||||||
|
/**
|
||||||
|
* Игнорируем если это наше прочтение
|
||||||
|
* которое получается при синхронизации
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`, [toPublicKey, fromPublicKey, publicKey]);
|
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`, [toPublicKey, fromPublicKey, publicKey]);
|
||||||
updateDialog(fromPublicKey);
|
updateDialog(fromPublicKey);
|
||||||
log("Read packet received from " + fromPublicKey + " for " + toPublicKey);
|
log("Read packet received from " + fromPublicKey + " for " + toPublicKey);
|
||||||
@@ -489,7 +497,7 @@ export function useDialogFiber() {
|
|||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}));
|
}));
|
||||||
}, [updateDialog]);
|
}, [updateDialog, publicKey]);
|
||||||
/**
|
/**
|
||||||
* Обработчик прочтения групповых сообщений
|
* Обработчик прочтения групповых сообщений
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default class Protocol extends EventEmitter {
|
|||||||
super();
|
super();
|
||||||
this.serverAddress = serverAddress;
|
this.serverAddress = serverAddress;
|
||||||
this.loadAllSupportedPackets();
|
this.loadAllSupportedPackets();
|
||||||
this.connect();
|
//this.connect();
|
||||||
|
|
||||||
let _this = this;
|
let _this = this;
|
||||||
this.waitPacket(0x00, (packet : PacketHandshake) => {
|
this.waitPacket(0x00, (packet : PacketHandshake) => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export const SERVERS = [
|
export const SERVERS = [
|
||||||
//'wss://cdn.rosetta-im.com',
|
//'wss://cdn.rosetta-im.com',
|
||||||
'ws://10.211.55.2:3000'
|
//'ws://10.211.55.2:3000',
|
||||||
|
'ws://127.0.0.1:8881'
|
||||||
];
|
];
|
||||||
|
|
||||||
export function selectServer(): string {
|
export function selectServer(): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user