Skip to content

Commit

Permalink
patch connect to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal Web committed Jul 9, 2023
1 parent f7f7274 commit 8477c7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
27 changes: 11 additions & 16 deletions udsp/server/actions/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function connect(reply) {
allowOrigin,
contentSecurityPolicy,
serverName,
encoding,
textEncoding,
language,
onConnectResponse,
response
Expand All @@ -15,35 +15,30 @@ export async function connect(reply) {
const server = reply.server();
const request = reply.data;
info(`Server ID${client.idString}`, `Client ID${client.clientIdString}`, `Stream ID${response.sid}`);
response.head = {};
response.data = {
sid: server.id
sid: response.sid
};
client.newKey = true;
if (cacheMaxAge) {
response.head.cacheMaxAge = cacheMaxAge;
reply.setHeader('cacheMaxAge', cacheMaxAge);
}
if (allowOrigin) {
response.head.allowOrigin = allowOrigin;
reply.setHeader('allowOrigin', allowOrigin);
}
if (contentSecurityPolicy) {
response.head.contentSecurityPolicy = contentSecurityPolicy;
reply.setHeader('contentSecurityPolicy', contentSecurityPolicy);
}
if (serverName) {
response.head.server = serverName;
reply.setHeader('serverName', serverName);
}
if (encoding) {
response.head.encoding = encoding;
if (textEncoding) {
reply.setHeader('encoding', textEncoding);
}
if (language) {
response.head.language = language;
reply.setHeader('language', language);
}
if (onConnectResponse) {
response.data.response = onConnectResponse;
response.data.message = onConnectResponse;
}
// connection status - backwards compatibility
response.state = 1;
reply.head.serialization = 'struct';
// REKEY THE CLIENT BEFORE SENDING BACK
reply.setHeader('serialization', 'struct');
reply.send();
}
4 changes: 2 additions & 2 deletions udsp/server/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { opn } from './connect.js';
import { connect } from './connect.js';
import { file } from './file.js';
import { reKey } from './reKey.js';
import { state } from './state.js';
export const actions = {
opn,
connect,
file,
reKey,
state
Expand Down

0 comments on commit 8477c7e

Please sign in to comment.