Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekmarchi committed Oct 5, 2023
1 parent 0ce5ae6 commit 27f90d1
Show file tree
Hide file tree
Showing 8 changed files with 1,534 additions and 62 deletions.
1,519 changes: 1,481 additions & 38 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"rollup": "^3.19.0",
"sodium-native": "^4.0.1",
"testatron": "^2.1.0",
"textlint": "^13.3.3",
"webtorrent": "^2.0.14"
},
"description": "Sentivate Network Client, Server Module, UDSP, Universal Web Socket, & certificate generation. This serves as a service & browser prototype.",
Expand Down
42 changes: 26 additions & 16 deletions udsp/UWRL/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
import { jsonParse } from '@universalweb/acid';
import { initialString, jsonParse, restString } from '@universalweb/acid';
class UWRL {
constructor(urlOriginal, paramaters) {
let url = urlOriginal;
if (paramaters) {
this.paramaters = paramaters;
}
if (url.includes('{')) {
const urlParts = urlOriginal.split('{');
url = urlParts[0];
const jsonStringStartIndex = url.indexOf('{');
console.log(jsonStringStartIndex, url[45]);
url = initialString(url, jsonStringStartIndex);
this.params = restString(url, jsonStringStartIndex).trim();
try {
this.paramaters = jsonParse(`{${urlParts[1]}`);
if (paramaters) {
if (paramaters['#']) {
this.hash = paramaters['#'];
}
}
this.paramaters = jsonParse(this.params);
} catch {
this.paramaters = {};
}
if (paramaters) {
if (paramaters['#']) {
this.hash = paramaters['#'];
}
if (paramaters[':']) {
this.account = paramaters[':'][0];
this.password = paramaters[':'][1];
}
}
}
console.log(url);
const urlObject = new URL(url);
console.log(urlObject);
this.href = url;
this.origin = urlObject.origin;
}
get search() {
return this.paramaterString;
Expand All @@ -33,11 +43,11 @@ class UWRL {
// Supports Username Password and URL Fragments
// Server can opt in to get the URL fragments
// fragments are turned into client side state tracking
const uwri = new UWRL('https://www.example.com:8080/path/to/resource{"query":"value", "#": "fragment also known as on the UW as state", ":": ["username", "password"]}');
const uwri = new UWRL('https://www.example.com:8080/path/to/resource{"query":"value", "#": "fragment", ":": ["username", "password"]}');
console.log(uwri);
const uwri2 = new UWRL('https://www.example.com:8080/path/to/resource', {
query: 'value',
'#': 'fragment',
'@': ['username', 'password']
});
console.log(uwri2);
// const uwri2 = new UWRL('https://www.example.com:8080/path/to/resource', {
// query: 'value',
// '#': 'fragment',
// '@': ['username', 'password']
// });
// console.log(uwri2);
4 changes: 4 additions & 0 deletions udsp/request/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,4 +582,8 @@ export class Base {
totalIncomingHeadSize = 0;
totalIncomingPathSize = 0;
totalReceivedUniqueDataPackets = 0;
onPathCurrentId = 0;
onParametersCurrentId = 0;
onHeadCurrentId = 0;
onDataCurrentId = 0;
}
2 changes: 1 addition & 1 deletion udsp/request/onData.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export async function onData(message) {
console.log('Incoming Progress', this.incomingProgress);
}
if (this.events.data) {
this.events.data(message.data, message.pid);
this.events.data(message.data, message.packetId);
}
}
13 changes: 13 additions & 0 deletions udsp/request/onDataSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function callOnDataSyncEvent() {
if (this.events.dataSync) {
this.events.dataSync(message.data, message.packetId);
}
}
export function onDataSync(message) {
if (message.packetId === this.onDataCurrentId) {

while (this.) {

}
}
}
2 changes: 1 addition & 1 deletion udsp/request/onHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export async function onHead(message) {
console.log('Incoming Progress', this.incomingProgress);
}
if (this.events.head) {
this.events.head(message.head, message.pid);
this.events.head(message.head, message.packetId);
}
}
13 changes: 7 additions & 6 deletions udsp/request/onPacket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { hasValue, isArray, isFalse } from '@universalweb/acid';
import {
hasValue, isArray, isFalse, isNumber,
} from '@universalweb/acid';
import { destroy } from './destory.js';
import { processEvent } from '#server/processEvent';
export async function onPacket(packet) {
Expand Down Expand Up @@ -112,7 +114,6 @@ export async function onPacket(packet) {
}
console.log(`DATA PROGRESS current:${this.currentIncomingDataSize}`, this.totalIncomingDataSize);
if (this.currentIncomingDataSize === this.totalIncomingDataSize) {
console.log(this);
console.log('Last packet received', this.currentIncomingDataSize, this.totalIncomingDataSize);
message.last = true;
this.totalIncomingUniqueDataPackets = packetId;
Expand All @@ -138,16 +139,16 @@ export async function onPacket(packet) {
this.method = method;
}
console.log(`Setup Packet Received HEADER:${totalIncomingHeadSize} DATA:${totalIncomingDataSize}`);
if (hasValue(totalIncomingPathSize)) {
if (hasValue(totalIncomingPathSize) && isNumber(totalIncomingPathSize)) {
this.totalIncomingPathSize = totalIncomingPathSize;
}
if (hasValue(totalIncomingParametersSize)) {
if (hasValue(totalIncomingParametersSize) && isNumber(totalIncomingParametersSize)) {
this.totalIncomingParametersSize = totalIncomingParametersSize;
}
if (hasValue(totalIncomingHeadSize)) {
if (hasValue(totalIncomingHeadSize) && isNumber(totalIncomingHeadSize)) {
this.totalIncomingHeadSize = totalIncomingHeadSize;
}
if (totalIncomingDataSize) {
if (hasValue(totalIncomingDataSize) && isNumber(totalIncomingDataSize)) {
this.totalIncomingDataSize = totalIncomingDataSize;
}
}
Expand Down

0 comments on commit 27f90d1

Please sign in to comment.