Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将'meteor.method'类型绑定到普通对象_Javascript_Meteor - Fatal编程技术网

Javascript 将'meteor.method'类型绑定到普通对象

Javascript 将'meteor.method'类型绑定到普通对象,javascript,meteor,Javascript,Meteor,这听起来可能很奇怪,但我有一门课。当我创建这个类时,我想生成很多meteor方法 Robot = class RobotServer extends RobotBase { // ... not terribly important // want to make this run as if it were a meteor method send(command) { if (Roles.userIsInRole(this.userId, 'operator', this

这听起来可能很奇怪,但我有一门课。当我创建这个类时,我想生成很多meteor方法

Robot = class RobotServer extends RobotBase {
  // ... not terribly important
  // want to make this run as if it were a meteor method
  send(command) {
    if (Roles.userIsInRole(this.userId, 'operator', this._id)) {
      this._sockets.get('commands').write(`${command}\r`);
    }
  }
}
我想把它暴露出来,就好像它是一种流星方法一样。也就是说,在我的客户身上,我可以做如下事情:

Baymax = new Robot();
Baymax.send('message "I am Baymax, your personal health care companion"', function (err, result) {
  console.log('command successfully sent.')
});

这在meteor中是可能的吗?

你能解释一下你想要实现什么吗?这些实例“存在”在哪里?为什么有许多方法而不是一个解释命令的方法?我想把
this.userId
this.connection
,以及所有绑定到
Meteor.method
的实例绑定到这些函数中。你能解释一下你想实现什么吗?这些实例“存在”在哪里?为什么有许多方法而不是一个解释命令的方法?我想把
this.userId
this.connection
,以及所有绑定到
Meteor.method
的实例绑定到这些函数。