GithubHelp home page GithubHelp logo

xirsys-nodejs's Introduction

xirsys-nodejs

Querying the Xirsys API with Nodejs

About V2

This is an example using Nodejs to securely query the Xirsys API from a serverside counterpart. Although we are using Nodejs in this example you can also use other technologies like PHP, Java, C# or whatever you prefer.

If you are looking for a more simple example of calling our API within node.js see this totorial: http://xirsys.com/node-js/

Start

Download and install the express module for Node.js globaly or in the root of the project.

npm install express

Open the server.js file included in the download, in any text editor.

Update the credentials for your account at the top of the document adding your ident, your secret token and domain information.

var ident = 'username'; //your username
var secret = 'fd50934c-57a5-4ad8-8d11-acae5786bcfb'; //your secret key
var domain = 'www.mydomain.com'; //your username
var application = 'default'; //your application name
var room = 'default'; //your room name

Add your secure certificate and key or create a self signed one.

key:fs.readFileSync(path.join( __dirname, 'server.key')),
cert:fs.readFileSync(path.join( __dirname, 'server.crt'))

From Terminal or a DOS prompt run the server file.

node server

NOTE: If using a self signed certificate you will get a warning and you will have to hit proceed from the browser to continue.

USING WEBRTC APP

Run the node server file and browse to https://localhost:8000/webrtc.html.

Login with a name, open a new browser window and browse to the same url and enter a different name.

Select the user from the list and click the call button. The other window should have an invite to chat popup, click to confirm.

Notice the events on the node server are called to securely retrieve the lists and tokens for the client chats.

USING TEST GUI

Run the node server file and browse to https://localhost:8000/test.html.

Click on each button in the GUI to tell node to return the information. If your info was entered correctly you should see the data populate within the text fields above each button respectfully.

xirsys-nodejs's People

Contributors

jerrychabolla avatar

Watchers

richardblakely avatar  avatar James Cloos avatar ritchie turner avatar Alex Thomas avatar Noe avatar  avatar

xirsys-nodejs's Issues

secure or insecure method?

In xirsys_connect.js, the secure method is also expecting secret etc on the client side.

// Secure method
var xirsysConnect = {
	secureTokenRetrieval : true,//change this to true for authenticating from server
	server : '/webrtc/',//<-- Path To Server Auth (node server listens to this path)
	data : {
		domain : '< www.yourdomain.com >',
		application : 'default',
		room : 'default',
		ident : '< Your username (not your email) >',
		secret : '< Your secret API token >',
		secure : 1
	}
};

errors in browser console

I slightly modified the server to use http

var server = http.createServer(app).listen(srvPort);

then, getting err in Chrome's console

xirsys.signal.js:238 WebSocket connection to 'wss://endpoint02.uswest.xirsys.com/ws/v2/....423rweq.....' failed: WebSocket opening handshake was cancelednext @ xirsys.signal.js:238
webrtc.html:294 error:  Event @ webrtc.html:294
http://192.168.1.x:8000/undefined Failed to load resource: the server responded with a status of 404 (Not Found)
webrtc.html:294 error:  undefined(anonymous function) @ webrtc.html:294
xirsys.signal.js:331 Uncaught TypeError: this.transport.send is not a function
    at constructor.send (http://192.168.1.x:8000/lib/xirsys.signal.js:331:28)
    at constructor.send (http://192.168.1.x:8000/lib/xirsys.signal.js:409:15)
    at HTMLFormElement.sendMessageEl.onsubmit (http://192.168.1.x:8000/webrtc.html:97:15)

Line numbers should be the same as in repo (didn't make any changes).

JSON body parser is unable to parse the payload

Most/all Express apps use the body-parser module to parse request payloads.

However, for some reason the JSON parser was failing on /webrtc/signal/token

  .use( bodyParser.json({ limit: '32kb',   strict: false,   type:'application/json' }))

Looks like you're sending invalid JSON string as payload

domain=domain.com&application=default&room=default&ident=username&secret=&secure=1&username=rewqrw&automaticAnswer=false&type=null
Name

server.js issue

Problem with server.js

When I'm trying login on https://localhost:8000/webrtc.html I got error message

Server on Port 8000
req:  GET  for:  /webrtc.html
req:  GET  for:  /css/video-call.css
req:  GET  for:  /xirsys_connect.js
req:  GET  for:  /lib/xirsys.core.js
req:  GET  for:  /lib/xirsys.signal.js
req:  GET  for:  /lib/xirsys.api.js
req:  GET  for:  /lib/xirsys.p2p.adapter.js
req:  GET  for:  /lib/xirsys.p2p.js
req:  GET  for:  /images/full-screen.png
req:  POST  for:  /webrtc/signal/token
GET SIGNAL TOKEN!
User request RTC Token username:  dssdds
RTC Token! /webrtc/signal/token {"s":200,"p":"/signal/token","e":null,"d":{"token":"ZCwtNEZcyTxVP0tLr_XZValWZQwDJ1t_aZSMjvy8o7oAwxEV53Pl3d_oF0TDYJmntDpzxdWahTGeS--hwb2J3gjUcT6QR4j_1xZ0-T1cg0NNbx_KL1dqmz_tE6qxOMXtK33tOx3bL72CMIPBfj0HP0RHPus0Z-X792FbnIj_-tSAFfrsiCuZrkexYA"}}

http.js:1166
      var keys = Object.keys(obj);
                        ^
TypeError: Object.keys called on non-object
    at Function.keys (native)
    at ServerResponse.writeHead (http.js:1166:25)
    at IncomingMessage.<anonymous> (/var/www/html/rarez_site/webrtc/test/xirsys-nodejs/xirsys_node_v2/server.js:74:21)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.