我尝试将node-vlc与nw.js(v0.12.0-alpha2)一起使用.当我启动我的应用程序没有nw.js它工作,但当我用nw.js启动它时,我收到一个错误:
未捕获的错误:模块没有自行注册.",来源:/home/alexis/Bureau/dev/jukebox/node_modules/vlc/node_modules/ffi/node_modules/bindings/bindings.js(84)
我用nw-gyp尝试了一些命令,但它无法帮助我.我在Ubuntu 14,64位.
我目前正在尝试向我的mongoose架构添加一个静态方法,但我找不到它不能以这种方式工作的原因.
我的模特:
import * as bcrypt from 'bcryptjs';
import { Document, Schema, Model, model } from 'mongoose';
import { IUser } from '../interfaces/IUser';
export interface IUserModel extends IUser, Document {
comparePassword(password: string): boolean;
}
export const userSchema: Schema = new Schema({
email: { type: String, index: { unique: true }, required: true },
name: { type: String, index: { unique: true }, required: true },
password: { type: String, required: true }
});
userSchema.method('comparePassword', function (password: string): boolean {
if …Run Code Online (Sandbox Code Playgroud) 我目前正在试验ECMA6课程.我目前的课程如下所示
class Player {
constructor(id) {
this.id = id;
this.cash = 350;
}
get cash() {
return this.cash;
}
set cash(value) { // line 19
this.cash = value; // line 20
}
};
Run Code Online (Sandbox Code Playgroud)
当我现在通过调用创建一个新的对象时,let playerObject = new Player(1);我收到以下错误
...\node_modules\mysql\lib\protocol\Parser.js:82
throw err;
^
RangeError: Maximum call stack size exceeded
at Player.cash (player.js:19:11)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15)
at Player.cash (player.js:20:15) …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试通过socket.io将.webm视频文件流式传输到我的客户端(目前使用Chrome作为客户端).
将第一个附加Uint8Array到SourceBuffer工作正常但附加更多的不起作用并引发以下错误:
Uncaught DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': The HTMLMediaElement.error attribute is not null.
我目前的代码:
'use strict';
let socket = io.connect('http://localhost:1337');
let mediaSource = new MediaSource();
let video = document.getElementById("player");
let queue = [];
let sourceBuffer;
video.src = window.URL.createObjectURL(mediaSource);
mediaSource.addEventListener('sourceopen', function() {
sourceBuffer = mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"');
socket.on("video", function(data) {
let uIntArray = new Uint8Array(data);
if (!sourceBuffer.updating) {
sourceBuffer.appendBuffer(uIntArray);
} else {
queue.push(data);
}
});
});
Run Code Online (Sandbox Code Playgroud)
服务器端代码(片段)
io.on('connection', function(socket) {
console.log("Client connected");
let readStream = fs.createReadStream("bunny.webm");
readStream.addListener('data', …Run Code Online (Sandbox Code Playgroud) 我目前正在寻找一种方法来检查每个字段是否可以访问,如果有的话,如果有办法到达每个字段而不使用字段两次.我目前的想法是尝试从各个方向开始,并使用旧场作为新墙.如果机器人卡住,他会重新启动并进入另一个方向.但我不确定这是否会起作用.性能如何?这甚至有用吗?
世界/墙壁和机器人的位置是随机的.机器人不能使用他之前使用的场.
我有一个带有枚举的架构:
export interface IGameMapModel extends IGameMap, Document {}
export const gameMapSchema: Schema = new Schema({
name: { type: String, index: { unique: true }, required: true },
type: { type: String, enum: CUtility.enumToArray(GameMode) }
});
export const GameMap: Model<IGameMapModel> = model<IGameMapModel>('GameMap', gameMapSchema);
Run Code Online (Sandbox Code Playgroud)
该GameMap是一个枚举。
第一个问题已经在这里:我需要将枚举转换为字符串数组,以便将它与架构一起使用。
其次,我想在模式创建期间直接使用枚举值。
new GameMap({
name: 'Test',
type: GameMode.ASSAULT
});
Run Code Online (Sandbox Code Playgroud)
返回 ValidationError: type: '1' is not a valid enum value for path 'type'.
由于我在模型枚举属性中设置的字符串数组,我不确定这是否真的可以工作。
我的想法是在模式创建期间创建某种类型转换。这是否适用于猫鼬,还是我必须为对象创建创建某种帮助程序?
我实现了 jsonwebtoken ( https://www.npmjs.com/package/jsonwebtoken ) 并制作了两个简单的函数。一种用于创建/签署具有到期时间的令牌,另一种用于验证令牌。
我用来jwt.sign('userdata', 'abc', {expiresInSeconds: 1});签署令牌。令牌应在一秒钟后过期,但是当我使用jwt.verify(token, 'abc', function(err, decoded) { }var验证令牌时,该令牌err为空并decoded返回userdata。
node.js ×6
javascript ×3
mongoose ×2
typescript ×2
algorithm ×1
enums ×1
jwt ×1
logic ×1
mongodb ×1
node-ffi ×1
node-mysql ×1
node-webkit ×1
socket.io ×1
stream ×1
video ×1