teleportxr 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -3
- package/package.json +4 -3
- package/scene/resources.js +9 -1
- package/signaling.js +13 -4
package/index.js
CHANGED
|
@@ -3,11 +3,11 @@ const WebRtcConnectionManager = require('./connections/webrtcconnectionmanager.j
|
|
|
3
3
|
const signaling =require("./signaling.js");
|
|
4
4
|
const client_manager = require('./client/client_manager.js');
|
|
5
5
|
|
|
6
|
-
function initServer() {
|
|
6
|
+
function initServer(signaling_port) {
|
|
7
7
|
var cm=client_manager.getInstance();
|
|
8
8
|
const webRtcConnectionManager = WebRtcConnectionManager.getInstance();
|
|
9
9
|
webRtcConnectionManager.SetSendConfigMessage(signaling.sendConfigMessage);
|
|
10
|
-
signaling.init(webRtcConnectionManager,cm.newClient.bind(cm));
|
|
10
|
+
return signaling.init(webRtcConnectionManager,cm.newClient.bind(cm),signaling_port);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
module.exports = {initServer}
|
|
13
|
+
module.exports = {initServer}
|
package/package.json
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"start": "node server.js"
|
|
13
13
|
},
|
|
14
14
|
"name": "teleportxr",
|
|
15
|
-
"description": "
|
|
16
|
-
"version": "1.0.
|
|
15
|
+
"description": "Teleport Spatial Server on node.js",
|
|
16
|
+
"version": "1.0.8",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git+https://github.com/simul/teleport-nodejs.git"
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"./signaling": "./signaling.js",
|
|
30
30
|
"./client/client_manager": "./client/client_manager.js",
|
|
31
31
|
"./connections/webrtcconnectionmanager": "./connections/webrtcconnectionmanager.js",
|
|
32
|
-
"./scene/scene":"./scene/scene.js"
|
|
32
|
+
"./scene/scene":"./scene/scene.js",
|
|
33
|
+
"./scene/resources":"./scene/resources.js"
|
|
33
34
|
},
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
}
|
package/scene/resources.js
CHANGED
|
@@ -9,6 +9,11 @@ class Resource
|
|
|
9
9
|
//! One trackedResources shared acrosss all clients.
|
|
10
10
|
static resourcesByUid=new Map();
|
|
11
11
|
static pathToUid=new Map();
|
|
12
|
+
static defaultPathRoot="http://localhost";
|
|
13
|
+
static SetDefaultPathRoot(str)
|
|
14
|
+
{
|
|
15
|
+
Resource.defaultPathRoot=str;
|
|
16
|
+
}
|
|
12
17
|
constructor(type,uid,url)
|
|
13
18
|
{
|
|
14
19
|
this.uid=uid;
|
|
@@ -18,7 +23,10 @@ class Resource
|
|
|
18
23
|
encodeIntoDataView(dataView,byteOffset) {
|
|
19
24
|
byteOffset=core.put_uint8(dataView,byteOffset,this.type);
|
|
20
25
|
byteOffset=core.put_uint64(dataView,byteOffset,this.uid);
|
|
21
|
-
|
|
26
|
+
var url=this.url;
|
|
27
|
+
if(this.url.search("://")==-1)
|
|
28
|
+
url=Resource.defaultPathRoot+this.url;
|
|
29
|
+
byteOffset=core.put_string(dataView,byteOffset,url);
|
|
22
30
|
return byteOffset;
|
|
23
31
|
}
|
|
24
32
|
}
|
package/signaling.js
CHANGED
|
@@ -214,17 +214,26 @@ function OnWebSocket(ws, req) {
|
|
|
214
214
|
console.log("Some Error occurred");
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
|
-
exports.init = function (webRtcCM,newClientFn) {
|
|
217
|
+
exports.init = function (webRtcCM, newClientFn, signaling_port) {
|
|
218
218
|
// Creating a new websocket server
|
|
219
|
-
const signaling_port = process.env.PORT || 8081;
|
|
220
|
-
|
|
219
|
+
// const signaling_port = process.env.PORT || 8081;
|
|
220
|
+
var wss;
|
|
221
|
+
if(signaling_port)
|
|
222
|
+
{
|
|
223
|
+
wss= new WebSocketServer.Server({ port: signaling_port});
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
{
|
|
227
|
+
wss= new WebSocketServer.Server({ noServer: true });
|
|
228
|
+
}
|
|
221
229
|
webRtcConnectionManager = webRtcCM;
|
|
222
230
|
newClient=newClientFn;
|
|
223
231
|
// Creating connection using websocket
|
|
224
232
|
wss.on("connection", (ws, req) => {
|
|
225
233
|
OnWebSocket(ws, req);
|
|
226
234
|
});
|
|
227
|
-
console.log("The WebSockets Signaling Server is running
|
|
235
|
+
console.log("The WebSockets Signaling Server is running: " + JSON.stringify(wss.options));
|
|
236
|
+
return wss;
|
|
228
237
|
};
|
|
229
238
|
exports.sendConfigMessage = function (clientID, msg) {
|
|
230
239
|
// Test: is this message valid json?
|