Skip to content

Commit

Permalink
chore: socket debbug
Browse files Browse the repository at this point in the history
  • Loading branch information
guimroque committed Nov 30, 2024
1 parent c966f54 commit 7aa57c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 7 additions & 7 deletions packages/socket-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ io.on(SocketEvents.CONNECT, async socket => {

socket.data.messageQueue = []
await socket.join(room)
console.log('Conexão estabelecida com o cliente:', room)
// console.log('Conexão estabelecida com o cliente:', room)
//console.log('[CONEXAO]: ', socket.handshake.auth, socket.id)

/*
Expand Down Expand Up @@ -77,27 +77,27 @@ io.on(SocketEvents.CONNECT, async socket => {
// Lidar com mensagens recebidas do cliente
socket.on(SocketEvents.DEFAULT, data => {
const { sessionId, to, request_id } = data
console.log('[SOCKET]: RECEIVED MESSAGE FROM', sessionId, to, request_id)
// console.log('[SOCKET]: RECEIVED MESSAGE FROM', sessionId, to, request_id)
const requestId = request_id === undefined ? '' : request_id
const room = `${sessionId}:${to}:${requestId}`

console.log('[SOCKET]: SEND MESSAGE TO', room)
// console.log('[SOCKET]: SEND MESSAGE TO', room)

socket.to(room).emit(SocketEvents.DEFAULT, data)
})

socket.on(SocketEvents.NOTIFICATION, data => {
const { sessionId, to } = data
const room = `${sessionId}:${to}`
console.log('[SOCKET]: REAL TIME MESSAGE TO FRONT', {
room, data
})
// console.log('[SOCKET]: REAL TIME MESSAGE TO FRONT', {
// room, data
// })

socket.to(room).emit(SocketEvents.NOTIFICATION, data)
})

socket.on('disconnect', () => {
console.log('Cliente desconectado:', socket.handshake.auth)
// console.log('Cliente desconectado:', socket.handshake.auth)
socket.disconnect(true)
// biome-ignore lint/complexity/noForEach: <explanation>
socket.rooms.forEach(room => socket.leave(room))
Expand Down
14 changes: 11 additions & 3 deletions packages/socket-server/src/modules/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ export class TransactionEventHandler {
const { auth } = socket.handshake

const dapp = await this.dappService.getBySessionIdWithPredicate(auth.sessionId)

const isValid = dapp && dapp.origin === origin
console.log('[DAPP]: ', JSON.stringify({
dapp,
origin,
host,
}))
const isValid = dapp //&& dapp.origin === origin

//todo: adicionar emissao de erro
if (!isValid) return
Expand All @@ -88,8 +92,12 @@ export class TransactionEventHandler {
predicateId: vault.id,
networkUrl: dapp.network.url,
})

console.log('TX_PENDING', dapp.network.url, tx_pending.count)
const provider = await Provider.create(dapp.network.url)

console.log('VAULT', provider.url)


const vaultInstance = new Vault(provider, JSON.parse(vault.configurable), vault.version)
const { tx } = await vaultInstance.BakoTransfer(_transaction)

Expand Down

0 comments on commit 7aa57c2

Please sign in to comment.