update changelog, do some tiny adjustment

This commit is contained in:
OttoMao 2015-08-12 20:05:47 +08:00
parent 531f4d0421
commit 130610fed6
7 changed files with 93 additions and 74 deletions

View File

@ -1,3 +1,9 @@
31 July: AnyProxy 3.7.3:
* show lastest 100 records when visit the web ui
* save map-local config file to local file
* show an indicator when filter or map-local is in use
31 July: AnyProxy 3.7.2:
* bugfix for issue #29

View File

@ -47,7 +47,8 @@ function resToMsg(msg,cb){
//config.port
function wsServer(config){
//web socket interface
var wss = new WebSocketServer({port: config.port});
var self = this,
wss = new WebSocketServer({port: config.port});
wss.broadcast = function(data) {
var key = data.id;
if(typeof data == "object"){
@ -86,9 +87,12 @@ function wsServer(config){
}
});
//Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding
return wss;
self.wss = wss;
}
wsServer.prototype.closeAll = function(){
var self = this;
self.wss.close();
}
module.exports = wsServer;

View File

@ -64,7 +64,8 @@ function proxyServer(option){
proxyConfigPort = option.webConfigPort || DEFAULT_CONFIG_PORT, //port to ui config server
disableWebInterface = !!option.disableWebInterface,
ifSilent = !!option.silent,
webServerInstance;
webServerInstance,
ws;
if(ifSilent){
logUtil.setPrintStatus(false);
@ -130,7 +131,7 @@ function proxyServer(option){
//start web socket service
function(callback){
var ws = new wsServer({port : socketPort});
ws = new wsServer({port : socketPort});
callback(null)
},

View File

@ -35,8 +35,8 @@ function util_merge(left,right){
(function(){
try{
var ws = window.ws = new Anyproxy_wsUtil({
baseUrl : document.getElementById("baseUrl").value,
port : document.getElementById("socketPort").value,
baseUrl : document.getElementById("baseUrl").value,
port : document.getElementById("socketPort").value,
onOpen : function(){
eventCenter.dispatchEvent("wsOpen");
},

View File

@ -26,46 +26,50 @@ function anyproxy_wsUtil(config){
var self = this;
var baseUrl = config.baseUrl || "127.0.0.1",
socketPort = config.port || 8003;
socketPort = config.port || 8003,
dataSocket;
var dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
function initSocket(){
self.bodyCbMap = {};
dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
dataSocket.onmessage = function(event){
config.onGetData && config.onGetData.call(self,event.data);
self.bodyCbMap = {};
dataSocket.onmessage = function(event){
config.onGetData && config.onGetData.call(self,event.data);
try{
var data = JSON.parse(event.data),
type = data.type,
content = data.content,
reqRef = data.reqRef;
}catch(e){
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
}
try{
var data = JSON.parse(event.data),
type = data.type,
content = data.content,
reqRef = data.reqRef;
}catch(e){
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
}
if(type == "update"){
config.onGetUpdate && config.onGetUpdate.call(self, content);
if(type == "update"){
config.onGetUpdate && config.onGetUpdate.call(self, content);
}else if(type == "body"){
config.onGetBody && config.onGetBody.call(self, content, reqRef);
}else if(type == "body"){
config.onGetBody && config.onGetBody.call(self, content, reqRef);
if(data.reqRef && self.bodyCbMap[reqRef]){
self.bodyCbMap[reqRef].call(self,content);
if(data.reqRef && self.bodyCbMap[reqRef]){
self.bodyCbMap[reqRef].call(self,content);
}
}
}
dataSocket.onopen = function(e){
config.onOpen && config.onOpen.call(self,e);
}
dataSocket.onclose = function(e){
config.onClose && config.onClose.call(self,e);
}
dataSocket.onerror = function(e){
config.onError && config.onError.call(self,e);
}
self.dataSocket = dataSocket;
}
dataSocket.onopen = function(e){
config.onOpen && config.onOpen.call(self,e);
}
dataSocket.onclose = function(e){
config.onClose && config.onClose.call(self,e);
}
dataSocket.onerror = function(e){
config.onError && config.onError.call(self,e);
}
self.dataSocket = dataSocket;
initSocket();
};
anyproxy_wsUtil.prototype.send = function(data){

View File

@ -81,8 +81,8 @@
(function(){
try{
var ws = window.ws = new Anyproxy_wsUtil({
baseUrl : document.getElementById("baseUrl").value,
port : document.getElementById("socketPort").value,
baseUrl : document.getElementById("baseUrl").value,
port : document.getElementById("socketPort").value,
onOpen : function(){
eventCenter.dispatchEvent("wsOpen");
},
@ -436,46 +436,50 @@
var self = this;
var baseUrl = config.baseUrl || "127.0.0.1",
socketPort = config.port || 8003;
socketPort = config.port || 8003,
dataSocket;
var dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
function initSocket(){
self.bodyCbMap = {};
dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
dataSocket.onmessage = function(event){
config.onGetData && config.onGetData.call(self,event.data);
self.bodyCbMap = {};
dataSocket.onmessage = function(event){
config.onGetData && config.onGetData.call(self,event.data);
try{
var data = JSON.parse(event.data),
type = data.type,
content = data.content,
reqRef = data.reqRef;
}catch(e){
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
}
try{
var data = JSON.parse(event.data),
type = data.type,
content = data.content,
reqRef = data.reqRef;
}catch(e){
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
}
if(type == "update"){
config.onGetUpdate && config.onGetUpdate.call(self, content);
if(type == "update"){
config.onGetUpdate && config.onGetUpdate.call(self, content);
}else if(type == "body"){
config.onGetBody && config.onGetBody.call(self, content, reqRef);
}else if(type == "body"){
config.onGetBody && config.onGetBody.call(self, content, reqRef);
if(data.reqRef && self.bodyCbMap[reqRef]){
self.bodyCbMap[reqRef].call(self,content);
if(data.reqRef && self.bodyCbMap[reqRef]){
self.bodyCbMap[reqRef].call(self,content);
}
}
}
dataSocket.onopen = function(e){
config.onOpen && config.onOpen.call(self,e);
}
dataSocket.onclose = function(e){
config.onClose && config.onClose.call(self,e);
}
dataSocket.onerror = function(e){
config.onError && config.onError.call(self,e);
}
self.dataSocket = dataSocket;
}
dataSocket.onopen = function(e){
config.onOpen && config.onOpen.call(self,e);
}
dataSocket.onclose = function(e){
config.onClose && config.onClose.call(self,e);
}
dataSocket.onerror = function(e){
config.onError && config.onError.call(self,e);
}
self.dataSocket = dataSocket;
initSocket();
};
anyproxy_wsUtil.prototype.send = function(data){

View File

@ -35,8 +35,8 @@ function util_merge(left,right){
(function(){
try{
var ws = window.ws = new Anyproxy_wsUtil({
baseUrl : document.getElementById("baseUrl").value,
port : document.getElementById("socketPort").value,
baseUrl : document.getElementById("baseUrl").value,
port : document.getElementById("socketPort").value,
onOpen : function(){
eventCenter.dispatchEvent("wsOpen");
},