- login account : mzcw2011@sina.cn
- set tb_api_key 46419702
set tb_api_secret b8f17a054ccde74e68453464ad6b1c879a75d030
- http://lesscss.org/features/#detached-rulesets-feature — 教程
- How to compile less to css , first use bower download third party component , then create own less which use above component , final use grunt compile it
-
1bower install --allow-root
1sudo npm install -g bower
first new a “bowe.json” file ,which content is :
1 2 3 4 5 6 |
{ "name": "opentok-rtc", "dependencies": { "theme": "tef-components/theme#0.2.68" } } |
then , install and download bower
1 |
sudo npm install -g bower |
1 |
bower install --allow-root |
bower install mean install the package specified in bower.json , in this case , tokbox company use the package :
https://github.com/tef-components/
this package is a free less lib for button, theme, text-input , etc .
For how to learn less , see
https://www.tutorialspoint.com/less/nested_rules.htm
a beginner less introduce in Chinese :
https://www.tutorialspoint.com/less/nested_rules.htm
- how to write rest server using swagger and node.js
a) first , how to do a simple node.js server
https://www.codementor.io/olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd
更好的是直接去看 expressjs 的 hello world : https://expressjs.com/en/starter/hello-world.html
b) opentok-rtc ‘s server is made by swager-boilerplate , which address is :
https://github.com/AntonioMA/swagger-boilerplate
In this site , it say : Simple implementation of a Node Express server described using a Swagger API, in JSON form.
how to make a Node Express server is in point a)
for swagger , here is a introduce article :
https://mherman.org/blog/swagger-and-nodejs/
c) swagger-boilerplate 用到了 .yml 文件作为 rest server api 定义文件 , yml 文件2个空格代表一个层级, 多个键值对用 – 分开
swagger api 的在线编辑界面 http://editor.swagger.io/
如何做一个简单的 swagger api : https://www.blazemeter.com/blog/create-your-first-openapi-definition-with-swagger-editor/
d) 怎么返回具体的页面
1) 可以在 expressjs 的js 文件 用 sendFile 返回 html , 但这里不是
2) 注意到 package.json 有 “ejs”: “^2.5.5”
3) 实际使用 的方法是 res.render(
4) how to use expressjs and ejs :
https://scotch.io/tutorials/use-ejs-to-template-your-node-application
—
here is a example : https://mherman.org/blog/swagger-and-nodejs/
- How to debug node.js
- JS 部分
- How and where to connect redis ?
显示所有key :
1 |
redis-cli KEYS '*' |
对某一个key取value
1 |
redis-cli -p 6379 GET mzcw2011@sina.cn |
这里假定 邮箱是key , server 端口 6379
如何从 node.js 存到 redis server ?
在 serverMethods.js中, register的post方法 , 写:
1 |
serverPersistence.setKey(aReq.body.email, JSON.stringify(aReq.body.username)); |
server停止后 , redis 存进去的数据还在
删除
1 |
redis-cli -p 6379 DEL mzcw2011@sina.cn |
ServerPersistence 是这样被初始化的 :
1 2 3 4 5 6 7 |
var ServerPersistence = SwaggerBP.ServerPersistence; var connectionString = (aModules && aModules.params && aModules.params.persistenceConfig) || env.REDIS_URL || env.REDISTOGO_URL || ''; //logger.log('connection string is ' + connectionString); var serverPersistence = new ServerPersistence([], connectionString, aLogLevel, aModules); |
SwaggerBP是从这里
var SwaggerBP = require(‘swagger-boilerplate’);
room 相关的 api 接口
getRoomArchive ——– 得到room 的所有 archive , 用 roomname 做参数
url 为 : https://47.52.61.15:8123/room/111/archive
首先, archive存在哪里 ?
archive 可以被保存的前提是 :
Important: You can only archive sessions that use the OpenTok Media Router (sessions with the media mode set to routed).
就是说只有特定类型的session, 它的archive 才可以被保存 。
如果配置了微软云或者亚马逊云, 会存到配置 ; 如果没有, 会存到 tokbox云, 只保存72小时 。
用户是否只能 record live stream as archive , 能不能上传录制好的视频
getroom 是建立一个临时的session , 以测试用户的音视频连接
getroominfo 是在 persistent store 查询房间号, 如果有, 进入
getUsableSessionInfo. 函数按房间号查询session, 如果没有, 创建新的