123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- Namespace.register("U.CV");
- U.CV.UL = function (URL, UOE, UEE, UME) {
- return new U.CV.ULinit(URL, UOE, UME).create(UME);
- }
- U.CV.ULinit = function (URL, UOE, UME) {
- this.USK; this.URL = URL || window.location.protocol + "//" + window.location.host; this.UOE = UOE;
- }
- U.CV.ULinit.prototype = {
- sockets: {},
- events: ["connect", "connect_failed", "error", "reconnecting", "reconnect", "disconnect"],
- create: function (UME) {
- if (this.sockets[this.URL]) { return this.sockets[this.URL]; }
- else {
- U.MD.DynamicLoad("http://socketio.1473.cn/socket.io/socket.io.js", "js", U.M.apply(this, [[this.Asyncreate, [UME]]]));
- return this;
- }
- },
- Asyncreate: function (UME) {
- var i, j, _UOE = this.UOE, _UEE = this.UEE, _UDE = this.events, _USE = this.USK = io.connect(this.URL, UME || { "reopen delay": 3000, "connect timeout": 5000, "try multiple transports": true, "reconnect": true, "max reconnection attempts": 10 });
- for (i = 0; i < _UDE.length; i++) { _USE.on(_UDE[i], this[_UDE[i]]); }
- for (i in _UOE) { if (_UOE.hasOwnProperty(i)) { _USE.on(i, U.M.apply(this, [[this.asyn, [_UOE[i]]]])); } }
- for (i = 0; i < _UEE.length; i++) { this.emit.apply(this, U.Ut.isArguments(_UEE[i]) ? _UEE[i] : [_UEE[i]]); } this.UEE = [];
- },
- abort: function () {
- this.USK.disconnect();
- },
- asyn: function (UDE) {
- var _UAE = Array.prototype.slice.call(arguments); _UAE.splice(0, 1);
- (UDE) && (UDE.apply(null, _UAE));
- },
- on: function () {
- var _UDE = arguments, _USE = this.USK;
- if (_UDE.length > 1) { _USE.on(_UDE[0], U.M.apply(this, [[this.on, [_UDE[1]]]])); }
- else if (U.Ut.isObject(_UDE)) { _UDE.Each(function (UVE, UIE) { _USE.on(_UIE, U.M.apply(this, [[this.on, [asyn]]])); }) }
- },
- emit: function (UME) {
- var i, _USE = this.USK;
- if (_USE) { if (U.Ut.isString(UME)) { _USE.emit.apply(_USE, arguments); } else { _$(UME).Each(function (UDE, UIE) { _USE.emit(UIE, UDE[UIE]); }); } }
- else { (!this.UEE) && (this.UEE = []); this.UEE.push(U.Ut.isString(UME) ? arguments : UME); } return this;
- },
- connect: function (UE) {
- },
- "connect_failed": function (UE) {
- },
- error: function () {
- },
- reconnecting: function () {
- },
- reconnect: function () {
- },
- disconnect: function () {
- }
- };
|