forked from zhoutony/html5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpub.js
More file actions
51 lines (38 loc) · 721 Bytes
/
pub.js
File metadata and controls
51 lines (38 loc) · 721 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Module dependencies.
*/
var Socket = require('./sock');
var slice = require('../utils').slice;
/**
* Expose `PubSocket`.
*/
module.exports = PubSocket;
/**
* Initialize a new `PubSocket`.
*
* @api private
*/
function PubSocket() {
Socket.call(this);
}
/**
* Inherits from `Socket.prototype`.
*/
PubSocket.prototype.__proto__ = Socket.prototype;
/**
* Send `msg` to all established peers.
*
* @param {Mixed} msg
* @api public
*/
PubSocket.prototype.send = function(msg){
var socks = this.socks;
var len = socks.length;
var sock;
var buf = this.pack(arguments);
for (var i = 0; i < len; i++) {
sock = socks[i];
if (sock.writable) sock.write(buf);
}
return this;
};