-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
29 lines (23 loc) · 1.05 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const WebRtcConnectionManager = require('./connections/webrtcconnectionmanager');
const cm = require('./client/client_manager.js');
const signaling=require("./signaling.js");
const scene=require("./scene/scene.js");
var sc=new scene.Scene();
sc.Load("assets/scene.json");
// This is our app's callback for when a new client is to be created.
// It must return the origin uid for the client.
function createNewClient(clientID) {
var origin_uid=sc.CreateNode();
return origin_uid;
}
// This will be called AFTER a client has been created, so we can access it from the clientManager.
function onClientPostCreate(clientID) {
var client=cm.getInstance().GetClient(clientID);
client.SetScene(sc);
}
const webRtcConnectionManager = WebRtcConnectionManager.getInstance();
webRtcConnectionManager.SetSendConfigMessage(signaling.sendConfigMessage);
cm.getInstance().SetNewClientCallback(createNewClient);
cm.getInstance().SetClientPostCreationCallback(onClientPostCreate);
signaling.init(webRtcConnectionManager,cm.getInstance().newClient.bind(cm.getInstance()));