Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
daonb committed Sep 26, 2024
1 parent 39f69d3 commit 8cfdaf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/peerbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export class PeerbookConnection {
connect(params?: ConnectParams) {
return new Promise<void>((resolve, reject) =>{
//TODO: firstMsg should be an array
const reconnectParams: ConnectParams = {...(params ?? {})}
let msgs = (params?.firstMsg)? [params?.firstMsg] : []
if (this.session) {
// check is connection in progress
Expand Down Expand Up @@ -310,8 +311,8 @@ export class PeerbookConnection {
switch (state) {
case 'connected':
// remove the first message so it won't be sent again
if (params)
params.firstMsg = undefined
if (reconnectParams)
reconnectParams.firstMsg = undefined
// send a ping to get the uid
this.getUID().then(uid => {
if (uid == "TBD") {
Expand All @@ -333,7 +334,7 @@ export class PeerbookConnection {
case 'failed':
case 'closed':
try {
await this.onDisconnect({params, failure})
await this.onDisconnect({params: reconnectParams, failure})
} catch(e) {
terminal7.log("onDisconnect failed", e)
reject(e)
Expand Down
2 changes: 1 addition & 1 deletion src/terminal7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ export class Terminal7 {
return
}
const toReconnect = gate?.boarding && (firstGate == "nope") && this.recovering && (gate.reconnectCount == 0)
console.log("toReconnect", toReconnect, "firstGate", firstGate, this.recovering, gate.reconnectCount)
this.log("toReconnect", toReconnect, "firstGate", firstGate, this.recovering, gate.reconnectCount)
if (toReconnect ) {
try {
await gate.reconnect()
Expand Down

0 comments on commit 8cfdaf2

Please sign in to comment.