Rename conn module to ngWebsockets

This commit is contained in:
David Cormier 2014-02-09 12:06:04 -05:00
parent 1b1b97c448
commit 1da061fec2
2 changed files with 15 additions and 15 deletions

View file

@ -205,13 +205,13 @@ weechat.factory('connection',
'$store', '$store',
'handlers', 'handlers',
'models', 'models',
'conn', 'ngWebsockets',
function($rootScope, function($rootScope,
$log, $log,
storage, storage,
handlers, handlers,
models, models,
conn) { ngWebsockets) {
protocol = new weeChat.Protocol(); protocol = new weeChat.Protocol();
@ -228,7 +228,7 @@ weechat.factory('connection',
// First command asks for the password and issues // First command asks for the password and issues
// a version command. If it fails, it means the we // a version command. If it fails, it means the we
// did not provide the proper password. // did not provide the proper password.
conn.sendAll([ ngWebsockets.sendAll([
weeChat.Protocol.formatInit({ weeChat.Protocol.formatInit({
password: passwd, password: passwd,
compression: noCompression ? 'off' : 'zlib' compression: noCompression ? 'off' : 'zlib'
@ -244,7 +244,7 @@ weechat.factory('connection',
} }
); );
conn.send( ngWebsockets.send(
weeChat.Protocol.formatHdata({ weeChat.Protocol.formatHdata({
path: 'buffer:gui_buffers(*)', path: 'buffer:gui_buffers(*)',
keys: ['local_variables,notify,number,full_name,short_name,title'] keys: ['local_variables,notify,number,full_name,short_name,title']
@ -263,7 +263,7 @@ weechat.factory('connection',
}); });
// Send all the other commands required for initialization // Send all the other commands required for initialization
conn.send( ngWebsockets.send(
weeChat.Protocol.formatHdata({ weeChat.Protocol.formatHdata({
path: "buffer:gui_buffers(*)/own_lines/last_line(-"+storage.get('lines')+")/data", path: "buffer:gui_buffers(*)/own_lines/last_line(-"+storage.get('lines')+")/data",
keys: [] keys: []
@ -272,7 +272,7 @@ weechat.factory('connection',
handlers.handleLineInfo(lineinfo); handlers.handleLineInfo(lineinfo);
}); });
conn.send( ngWebsockets.send(
weeChat.Protocol.formatHdata({ weeChat.Protocol.formatHdata({
path: "hotlist:gui_hotlist(*)", path: "hotlist:gui_hotlist(*)",
keys: [] keys: []
@ -281,14 +281,14 @@ weechat.factory('connection',
handlers.handleHotlistInfo(hotlist); handlers.handleHotlistInfo(hotlist);
}); });
conn.send( ngWebsockets.send(
weeChat.Protocol.formatNicklist({ weeChat.Protocol.formatNicklist({
}) })
).then(function(nicklist) { ).then(function(nicklist) {
handlers.handleNicklist(nicklist); handlers.handleNicklist(nicklist);
}); });
conn.send( ngWebsockets.send(
weeChat.Protocol.formatSync({}) weeChat.Protocol.formatSync({})
); );
@ -315,12 +315,11 @@ weechat.factory('connection',
$log.error("Relay error " + evt.data); $log.error("Relay error " + evt.data);
}; };
protocol.setId = function(id, message) { protocol.setId = function(id, message) {
return '(' + id + ') ' + message; return '(' + id + ') ' + message;
} }
conn.connect(url, ngWebsockets.connect(url,
protocol, protocol,
{ {
'binaryType': "arraybuffer", 'binaryType': "arraybuffer",
@ -334,7 +333,7 @@ weechat.factory('connection',
var disconnect = function() { var disconnect = function() {
/* TODO: Send protocol disconnect */ /* TODO: Send protocol disconnect */
conn.disconnect(); ngWebsockets.disconnect();
}; };
/* /*
@ -343,14 +342,14 @@ weechat.factory('connection',
* @returns the angular promise * @returns the angular promise
*/ */
var sendMessage = function(message) { var sendMessage = function(message) {
conn.send(weeChat.Protocol.formatInput({ ngWebsockets.send(weeChat.Protocol.formatInput({
buffer: models.getActiveBuffer().fullName, buffer: models.getActiveBuffer().fullName,
data: message data: message
})); }));
}; };
var sendCoreCommand = function(command) { var sendCoreCommand = function(command) {
conn.send(weeChat.Protocol.formatInput({ ngWebsockets.send(weeChat.Protocol.formatInput({
buffer: 'core.weechat', buffer: 'core.weechat',
data: command data: command
})); }));

View file

@ -1,12 +1,13 @@
var websockets = angular.module('ngWebsockets', []); var websockets = angular.module('ngWebsockets', []);
websockets.factory('conn', websockets.factory('ngWebsockets',
['$rootScope','$q', ['$rootScope','$q',
function($rootScope, $q) { function($rootScope, $q) {
var ws = null;
this.protocol = null; this.protocol = null;
var ws = null;
var callbacks = {}; var callbacks = {};
var currentCallBackId = 0; var currentCallBackId = 0;