Sha256: dfd6f65ca6e9ecfb872f8887e8ef80daae2b5a47b0592f5194d90f36778ad974

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

/*
The socket component is an interface for the new HTML5 websockets.

Its safe to use this abstraction incase specs change in the future.

*/
re.c('socket')
.defines({
	
	connect:function(address){
		
		this.socket = new WebSocket(address);
		
	},
	
	close:function(){
		if(!this.socket) return this;
		
		this.socket.close();
		
		return this;
	},
	
	open:function(callback){
		if(!this.socket) return this;
		
		this.socket.onopen = callback;
		
	},
	
	error:function(callback){
		if(!this.socket) return this;
		
		this.socket.onerror = callback;
		
	},
	
	message:function(callback){
		if(!this.socket) return this;
		
		this.socket.onmessage = callback;
		
	},
	
	send:function(){
		if(!this.socket) return this;
		
		this.socket.send.apply(this.socket, arguments);
		
	}
	
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
entityjs-0.3.2 src/net/socket.js
entityjs-0.3.1 src/net/socket.js
entityjs-0.3.0 src/net/socket.js