Skip to content

Commit

Permalink
reconnecting AS4 to the newly formatted WebHUB websocket protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogo-mit committed Jan 6, 2024
1 parent fea4713 commit af0e7fe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/pages/_app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Router.events.on('routeChangeError', () => NProgress.done());
export default function AnnotationStudio({ Component, pageProps }) {
const [session, setSession] = useState(pageProps.session);

const [socketUrl, setSocketUrl] = useState('wss://wq5pn518mf.execute-api.us-east-2.amazonaws.com/dev/');
const [socketUrl, setSocketUrl] = useState('wss://9tn6yisxy0.execute-api.us-east-2.amazonaws.com/dev/');
const [messageHistory, setMessageHistory] = useState([]);
const [websocketID, setWebsocketID] = useState();

Expand Down
1 change: 1 addition & 0 deletions src/pages/api/document/slug/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const handler = async (req, res) => {
const token = await getToken({ req, secret });
if (token && token.exp > 0) {
const { db } = await connectToDatabase();
// console.log('variable info: ', db);
const userObj = await db
.collection('users')
.findOne({ _id: ObjectID(token.sub) });
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/group/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const handler = async (req, res) => {
.toArray();
if (doc[0]) {
const group = doc[0];
console.log('db group: ', group)

const {
name,
members,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/user/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const handler = async (req, res) => {
const {
name, firstName, lastName, affiliation, role,
} = doc[0];
console.log('doc[0]: ', doc[0])

const groups = doc[0].groups ? doc[0].groups : [];
if (querierRole === 'admin') {
const {
Expand Down
42 changes: 21 additions & 21 deletions src/pages/documents/[slug]/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -785,22 +785,22 @@ const DocumentPage = ({

// mangage data coming into the websocket

console.log('lastJsonMessage: ', lastJsonMessage)

const {
status,
res: {
// messages
$enter_rm,
$set_rm,
$notification_rm,
$disconnect,
// requests
$set,
$get,
},
// info
connectionId,
rm,
// broadcast keys: $enter_rm, $set, $notification, $disconnect,
broadcast,

// response keys: $enter_rm, $set_rm, $notification, $set, $get,
response,

} = lastJsonMessage;

if ($enter_rm) {
const { connectionId, data: { user, withGroupId } } = $enter_rm;
if (broadcast?.$enter_rm) {
const { connectionId, data: { user, withGroupId } } = broadcast.$enter_rm;

const msg = {
date: new Date(),
Expand Down Expand Up @@ -848,9 +848,9 @@ const DocumentPage = ({

}

if ($set_rm && $set_rm.connectionId !== $enter_rm?.connectionId) {
if (broadcast?.$set_rm) {

const { connectionId, data: { user, withGroupId } } = $set_rm;
const { connectionId, data: { user, withGroupId } } = broadcast.$set_rm;

const views = DeepCopyObj(websocketViews);

Expand All @@ -873,10 +873,10 @@ const DocumentPage = ({

}

if ($disconnect) {
if (broadcast?.$disconnect) {
const views = DeepCopyObj(websocketViews);

$disconnect.map(({ rm, connectionId, data: { user, withGroupId} }) => {
broadcast.$disconnect.map(({ rm, connectionId, data: { user, withGroupId} }) => {

if (rm === websocketRMID) {

Expand Down Expand Up @@ -934,11 +934,11 @@ const DocumentPage = ({

}

if ($notification_rm) {
if (broadcast?.$notification) {
const {
connectionId,
data,
} = $notification_rm;
} = broadcast.$notification;

const {
annotation,
Expand Down Expand Up @@ -993,8 +993,8 @@ const DocumentPage = ({
setPulseWebsocketButton(true);
}

if ($get) {
const { data } = $get;
if (response?.$get) {
const { data } = response.$get;

const views = DeepCopyObj(websocketViews);

Expand Down

0 comments on commit af0e7fe

Please sign in to comment.