Skip to content

Commit

Permalink
Merge branch 'billboard-devconnect' of https://github.com/corpus-io/dm3
Browse files Browse the repository at this point in the history
… into billboard-devconnect
AlexNi245 committed Nov 9, 2023
2 parents a788aee + 6e313f1 commit 219b65f
Showing 3 changed files with 30 additions and 6 deletions.
13 changes: 13 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -82,6 +82,19 @@ http {
proxy_set_header Host $host;
}

location /bb-client/socket.io {
rewrite ^/bb-client(.*)$ $1 break;
proxy_pass http://billboard-client:8083/socket.io;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_set_header Host $host;
}


}
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import { Message } from 'dm3-lib-messaging';
import http from 'http';
import { Server, Socket } from 'socket.io';
import { IViewerService } from './IViewerService';
import { logDebug } from 'dm3-lib-shared';

/**
* Creates and returns an instance of a viewer service that manages viewer connections and message broadcasting.
@@ -20,6 +21,12 @@ export function ViewerService(httpServer: http.Server): IViewerService {
const connections: Map<string, Socket> = new Map();

const addConnection = (connection: Socket) => {
logDebug({
text: '[ViewerService] connect',
id: connection.id,
connectionsSize: connections.size,
});

//When the socket disconnects we wan't them no longer in our viewers List
connection.on('disconnect', () => {
removeConnection(connection);
@@ -28,10 +35,19 @@ export function ViewerService(httpServer: http.Server): IViewerService {
};

const removeConnection = (connection: Socket) => {
logDebug({
text: '[ViewerService] disconnect',
id: connection.id,
connectionsSize: connections.size,
});
connections.delete(connection.id);
};

const getViewerCount = () => {
logDebug({
text: '[ViewerService] getViewerCount',
connectionsSize: connections.size,
});
return connections.size;
};

7 changes: 1 addition & 6 deletions packages/lib/delivery/src/UserProfile.ts
Original file line number Diff line number Diff line change
@@ -38,12 +38,10 @@ export async function submitUserProfile(
send: (socketId: string) => void,
): Promise<string> {
const account = normalizeEnsName(ensName);
console.log('1', account, signedUserProfile);

if (!(await checkUserProfile(provider, signedUserProfile, account))) {
throw Error('Signature invalid.');
}
console.log('2', process.env.DISABLE_SESSION_CHECK);
//TODO: remvoe DISABLE_SESSION_CHECK
// DISABLE_SESSION_CHECK is a special solution for ETH Prague
if (
@@ -52,25 +50,22 @@ export async function submitUserProfile(
) {
throw Error('Profile exists already');
}
console.log('3');
const session: Session = {
account,
signedUserProfile,
token: uuidv4(),
createdAt: new Date().getTime(),
profileExtension: getDefaultProfileExtension(),
};
console.log('4', session);

await setSession(account.toLocaleLowerCase(), session);
console.log('5');
await handlePendingConversations(
account,
getSession,
getPendingConversations,
send,
);
console.log('6');

return session.token;
}

0 comments on commit 219b65f

Please sign in to comment.