Skip to content

Commit ae600d7

Browse files
author
Gilgamesh
committed
testing
1 parent f1d1f71 commit ae600d7

File tree

8 files changed

+64
-24
lines changed

8 files changed

+64
-24
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"gh-publish-mac": "electron-builder build --x64 --mac -p always",
3232
"gh-publish": "electron-builder build -mwl -p always",
3333
"check-types": "tsc",
34-
"postinstall": "patch-package"
34+
"postinstall": "NODE_OPTIONS=--no-node-snapshot patch-package"
3535
},
3636
"build": {
3737
"npmRebuild": false,
@@ -47,7 +47,7 @@
4747
"preload.js",
4848
"src/server/*"
4949
],
50-
"nodeVersion": "16.15.0",
50+
"nodeVersion": "18.18.0",
5151
"nsis": {
5252
"createDesktopShortcut": "always"
5353
},
@@ -91,7 +91,7 @@
9191
"license": "MIT",
9292
"homepage": "http://www.getswell.io",
9393
"engines": {
94-
"node": ">=16.15.0",
94+
"node": ">=18.0.0",
9595
"npm": ">=7.0.0"
9696
},
9797
"dependencies": {
@@ -139,11 +139,12 @@
139139
"graphql-tag": "^2.12.6",
140140
"graphql-ws": "^5.8.1",
141141
"highland": "^2.13.5",
142-
"isolated-vm": "^4.6.0",
142+
"isolated-vm": "^5.0.3",
143143
"jest-environment-jsdom": "^29.7.0",
144144
"mali": "^0.46.1",
145145
"ngrok": "^4.3.1",
146146
"node-fetch": "^3.3.0",
147+
"node-gyp": "^11.0.0",
147148
"npm": "^8.7.0",
148149
"patch-package": "^6.4.7",
149150
"path": "^0.12.7",
@@ -572,4 +573,3 @@
572573
}
573574
]
574575
}
575-

src/client/components/main/WebRTC-composer/WebRTCComposer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default function WebRTCComposer() {
2828
const [showRTCEntryForms, setShowRTCEntryForms] = useState(false);
2929

3030
// Builds ReqRes object from properties in NewRequest
31+
3132
const composeReqRes = (): ReqRes => {
3233
return {
3334
id: uuid(),
@@ -87,6 +88,7 @@ export default function WebRTCComposer() {
8788
style={{ overflowX: 'hidden' }}
8889
>
8990
<WebRTCSessionEntryForm setShowRTCEntryForms={setShowRTCEntryForms} />
91+
9092
{showRTCEntryForms && (
9193
<>
9294
<WebRTCServerEntryForm />

src/client/components/main/WebRTC-composer/WebRTCServerEntryForm.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const WebRTCServerEntryForm: React.FC<Props> = (props: Props) => {
3434
<TextCodeArea
3535
mode={'application/json'}
3636
value={newRequestWebRTC.webRTCOffer || ''}
37-
height={'85px'}
37+
height={'85px'}
3838
onChange={(value, viewUpdate) => {
3939
dispatch(
4040
newRequestWebRTCSet({ ...newRequestWebRTC, webRTCOffer: value })
@@ -82,6 +82,7 @@ const WebRTCServerEntryForm: React.FC<Props> = (props: Props) => {
8282
className="button is-normal is-primary-100 add-request-button no-border-please"
8383
style={{ margin: '10px' }}
8484
onClick={() => {
85+
console.log('newRequestWebRTCfromOclick:', newRequestWebRTC);
8586
webrtcPeerController.createOffer(newRequestWebRTC);
8687
}}
8788
>
@@ -138,16 +139,29 @@ const WebRTCServerEntryForm: React.FC<Props> = (props: Props) => {
138139
Paste
139140
</button>
140141
{/* ANSWER BUTTON IS WORK-IN-PROGRESS */}
141-
{/* <button
142+
<button
142143
id="webRTButton"
143144
className="button is-normal is-primary-100 add-request-button no-border-please"
144145
style={{ margin: '10px' }}
145146
onClick={() => {
146-
createAnswer(newRequestWebRTC);
147+
console.log('newRequestWebRTCfromGAclick:', newRequestWebRTC);
148+
webrtcPeerController.createAnswer(newRequestWebRTC);
147149
}}
148150
>
149151
Get Answer
150-
</button> */}
152+
</button>
153+
154+
<button
155+
id="webRTButton"
156+
className="button is-normal is-primary-100 add-request-button no-border-please"
157+
style={{ margin: '10px' }}
158+
onClick={() => {
159+
console.log('newRequestWebRTCfromAAclick:', newRequestWebRTC);
160+
// webrtcPeerController.addAnswer(reqRes);
161+
}}
162+
>
163+
Add Answer
164+
</button>
151165
{/* {warningMessage ? <div>{warningMessage.body}</div> : null} */}
152166
</div>
153167
</div>

src/client/components/main/WebRTC-composer/WebRTCSessionEntryForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const WebRTCSessionEntryForm: React.FC<Props> = (props: Props) => {
131131
className="ml-1 is-rest button no-border-please"
132132
onClick={() => {
133133
setShowRTCEntryForms(true);
134+
console.log('newRequestWebRTCFromCclick:', newRequestWebRTC);
134135
webrtcPeerController.createPeerConnection(newRequestWebRTC);
135136
}}
136137
>

src/client/controllers/webrtcPeerController.ts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const webrtcPeerController = {
1616
newRequestWebRTC: RequestWebRTC
1717
): Promise<void> => {
1818
let servers = {
19-
iceServers: [
19+
iceServers: [
2020
{
2121
urls: [
22-
'stun:stun1.1.google.com:19302',
23-
'stun:stun2.1.google.com:19302',
22+
'stun:stun.l.google.com:19302',
23+
'stun:stun.l.google.com:5349',
2424
],
2525
},
2626
],
@@ -73,42 +73,63 @@ const webrtcPeerController = {
7373
let localStream = peerConnection.createDataChannel('textChannel');
7474
localStream.onopen = () => console.log('data channel opened');
7575
localStream.onclose = () => console.log('data channel closed')
76-
76+
console.log('peerConnection:', peerConnection)
77+
console.log('localstream:', localStream)
78+
console.log('newRequestWebRTCcheck:', newRequestWebRTC)
7779
appDispatch(
7880
newRequestWebRTCSet({
7981
...newRequestWebRTC,
8082
webRTCpeerConnection: peerConnection,
8183
webRTCLocalStream: localStream,
8284
})
8385
);
84-
86+
8587
peerConnection.onicecandidate = async (
8688
event: RTCPeerConnectionIceEvent
8789
): Promise<void> => {
90+
console.log('event:', event)
8891
if (event.candidate) {
8992
appDispatch(
90-
newRequestWebRTCOfferSet(
93+
newRequestWebRTCOfferSet( // newRequestWebRTCOfferSet mutates the newRequestWebRTC.webrtcOffer state
9194
JSON.stringify(peerConnection.localDescription)
9295
)
9396
);
9497
}
98+
console.log('newRequestWebRTCCheck4:', newRequestWebRTC)
9599
};
100+
96101
}
97102
},
98103

99104
createOffer: async (newRequestWebRTC: RequestWebRTC): Promise<void> => {
100105
//grab the peer connection off the state to manipulate further
106+
console.log('newRequestWebRTCCheck2:', newRequestWebRTC)
101107
let { webRTCpeerConnection } = newRequestWebRTC;
108+
console.log('webRTCPeerConnect:', webRTCpeerConnection)
102109
let offer = await webRTCpeerConnection!.createOffer();
103-
await webRTCpeerConnection!.setLocalDescription(offer);
110+
console.log('offer:', offer)
111+
await webRTCpeerConnection!.setLocalDescription(offer); //what is this line doing that is not already done?
112+
console.log('webRTCaftersetofLocalDes:', webRTCpeerConnection)
104113
appDispatch(
105114
newRequestWebRTCSet({
106115
...newRequestWebRTC,
107116
webRTCOffer: JSON.stringify(offer),
108117
})
109118
);
119+
console.log('newRequestWebRTCCheck3:', newRequestWebRTC)
110120
},
111121

122+
// need to include methodology to send offer to other peer
123+
124+
// also need to send ice candidate to other peer
125+
126+
// Ability to receive offer and candidate from other peer (using websockets)
127+
128+
// peer should be able to accept offer and candidate
129+
// peer should be able to set the offer received as the remote description
130+
131+
132+
112133
// work-in-progress
113134
createAnswer: async (newRequestWebRTC: RequestWebRTC): Promise<void> => {
114135
let { webRTCpeerConnection, webRTCOffer } = newRequestWebRTC;
@@ -121,12 +142,13 @@ const webrtcPeerController = {
121142
let answer = await webRTCpeerConnection.createAnswer();
122143
await webRTCpeerConnection.setLocalDescription(answer);
123144

124-
appDispatch(
145+
appDispatch(
125146
newRequestWebRTCSet({
126147
...newRequestWebRTC,
127148
webRTCAnswer: JSON.stringify(answer),
128149
})
129150
);
151+
console.log('newRequestWebRTCCheck5:', newRequestWebRTC)
130152
},
131153

132154
addAnswer: async (reqRes: ReqRes): Promise<void> => {

src/server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const cookieParser = require('cookie-parser');
66
const crypto = require('crypto');
77
dotenv.config();
88

9-
const port = 3000;
9+
const port = 3001;
1010
const app = express();
1111
const cors = require('cors');
1212
app.use(express.urlencoded({ extended: true }));

webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ module.exports = {
129129
'base-uri': ["'self'"],
130130
'default-src': [
131131
"'self'",
132-
'http://localhost:3000',
133-
'ws://localhost:3000',
132+
'http://localhost:3001',
133+
'ws://localhost:3001',
134134
'https://api.github.com',
135135
"'unsafe-inline'",
136136
"'unsafe-eval'",

webpack.development.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ module.exports = merge(base, {
1313
compress: true,
1414
proxy: {
1515
'/webhookServer': {
16-
target: 'http://localhost:3000',
16+
target: 'http://localhost:3001',
1717
},
1818
'/webhook': {
19-
target: 'http://localhost:3000',
19+
target: 'http://localhost:3001',
2020
},
2121
'/api': {
22-
target: 'http://localhost:3000',
22+
target: 'http://localhost:3001',
2323
/**
2424
* @todo Change secure option to true, and refactor code to account for
25-
* change
25+
* change // https://github.com/electron/electron/issues/19775 ??? maybe this is the solution
2626
*/
2727
secure: false,
2828
},
@@ -31,6 +31,7 @@ module.exports = merge(base, {
3131
if (!devServer) {
3232
throw new Error('webpack-dev-server is not defined');
3333
}
34+
console.log('Setting up middlewares...:', middlewares);
3435
middlewares.unshift({
3536
// unshift does not work, ends in infinite calls to this function
3637
name: 'run-in-electron',

0 commit comments

Comments
 (0)