Move specific weechat websocket manipulation in glowingbear.js
This commit is contained in:
parent
a49ce938ea
commit
81054f06bd
1 changed files with 29 additions and 7 deletions
|
@ -206,7 +206,7 @@ weechat.factory('connection',
|
||||||
'handlers',
|
'handlers',
|
||||||
'models',
|
'models',
|
||||||
'ngWebsockets',
|
'ngWebsockets',
|
||||||
function($rootScope,
|
function($rootScope,
|
||||||
$log,
|
$log,
|
||||||
storage,
|
storage,
|
||||||
handlers,
|
handlers,
|
||||||
|
@ -216,6 +216,28 @@ weechat.factory('connection',
|
||||||
protocol = new weeChat.Protocol();
|
protocol = new weeChat.Protocol();
|
||||||
|
|
||||||
// Takes care of the connection and websocket hooks
|
// Takes care of the connection and websocket hooks
|
||||||
|
|
||||||
|
var _formatForWs = function(message) {
|
||||||
|
/*
|
||||||
|
* Formats a weechat message to be sent over
|
||||||
|
* the websocket.
|
||||||
|
*/
|
||||||
|
message.replace(/[\r\n]+$/g, "").split("\n");
|
||||||
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
|
var _send = function(message) {
|
||||||
|
return ngWebsockets.send(_formatForWs(message));
|
||||||
|
};
|
||||||
|
|
||||||
|
var _sendAll = function(messages) {
|
||||||
|
for (var i in messages) {
|
||||||
|
messages[i] = _formatForWs(messages[i]);
|
||||||
|
}
|
||||||
|
return ngWebsockets.sendAll(messages);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var connect = function (host, port, passwd, ssl, noCompression) {
|
var connect = function (host, port, passwd, ssl, noCompression) {
|
||||||
var proto = ssl ? 'wss' : 'ws';
|
var proto = ssl ? 'wss' : 'ws';
|
||||||
var url = proto + "://" + host + ":" + port + "/weechat";
|
var url = proto + "://" + host + ":" + port + "/weechat";
|
||||||
|
|
Loading…
Reference in a new issue