now = function() {
if (Date.now) {
return Date.now();
} else {
return new Date().valueOf;
}
};
Date.now 是什么意思?
/*
* 时间:2018年1月28日
*/
(function() {
var Byte, Client, Frame, Stomp,
__hasProp = {}.hasOwnProperty,
__slice = [].slice;
Byte = {
LF: '\x0A',
NULL: '\x00'
};
Client = (function() {
var now;
function Client(ws) {
this.ws = ws;
this.ws.binaryType = "arraybuffer";
this.counter = 0;
this.connected = false;
this.heartbeat = {
outgoing: 10000,
incoming: 10000
};
this.maxWebSocketFrameSize = 16 * 1024;
this.subscriptions = {};
this.partialData = '';
}
Client.prototype.console = function(message) {
console.log(message)
};
Client.prototype.debug = function(message) {
var _ref;
return typeof window !== "undefined" && window !== null ? (_ref = window.console) != null ? _ref.log(message) : void 0 : void 0;
};
now = function() {
if (Date.now) {
return Date.now();
} else {
return new Date().valueOf;
}
};
return Client;
})();
Stomp = {
VERSIONS: {
V1_0: '1.0',
V1_1: '1.1',
V1_2: '1.2',
supportedVersions: function() {
return '1.1,1.0';
}
},
client: function(url, protocols) {
var klass, ws;
if (protocols == null) {
protocols = ['v10.stomp', 'v11.stomp'];
}
klass = Stomp.WebSocketClass || WebSocket;
ws = new klass(url, protocols);
return new Client(ws);
},
over: function(ws) {
return new Client(ws);
},
Frame: Frame
};
if (typeof exports !== "undefined" && exports !== null) {
exports.Stomp = Stomp;
}
if (typeof window !== "undefined" && window !== null) {
Stomp.setInterval = function(interval, f) {
return window.setInterval(f, interval);
};
Stomp.clearInterval = function(id) {
return window.clearInterval(id);
};
window.Stomp = Stomp;
} else if (!exports) {
self.Stomp = Stomp;
}
}).call(this);
import React from 'react';
import AStomp from '../../utils/aStomp'
class Basic extends React.Component {
constructor() {
super();
}
componentDidMount() {
var aClient;
aClient = AStomp.Stomp.client('ws://10.0.5.232:61623');
aClient.console('消息到来了');
console.log(new Date().valueOf)
AStomp.Stomp.debug('debug')
}
render() {
var divStyle = {
}
return (
<div id style={divStyle} className='data-line'>
<h1>indexStomp</h1>
<h1>A</h1>
</div>
)
}
}
export default Basic;
1.
Date.now
是返回当前时间的时间戳,但是不是所有的浏览器都支持2.应该是用
AStomp.Stomp.client.debug('debug')