Skip to content

Commit

Permalink
more work on websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
lformella committed Nov 19, 2012
1 parent 885faf9 commit 7466429
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 234 deletions.
1 change: 1 addition & 0 deletions Core/Server.cs
Expand Up @@ -46,6 +46,7 @@ public override bool Connected
foreach (AObject obj in All)
{
obj.Connected = false;
obj.Commit();
}
}
base.Connected = value;
Expand Down
Binary file added Lib/Newtonsoft.Json.dll
Binary file not shown.
Binary file added Server.Plugin.General.Webserver/Lib/Fleck.dll
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 26 additions & 16 deletions Server.Plugin.General.Webserver/Resources/js/xg/main.js
Expand Up @@ -130,19 +130,24 @@ var XGBase = Class.create(
hidegrid: false
}).navGrid('#servers_pager', {edit:false, search:false}, {},
{
mtype: "GET",
url: "/",
serializeEditData: function (postdata)
processing: true,
reloadAfterSubmit: false,
savekey: [true,13],
closeOnEscape: true,
closeAfterAdd: true,
onclickSubmit: function (options, obj)
{
return { request: Enum.Request.AddServer, name: postdata.Name };
self.websocket.sendName(Enum.Request.AddServer, obj.Name);
return {};
}
},
{
mtype: "GET",
url: "/",
serializeDelData: function (postdata)
processing: true,
closeOnEscape: true,
onclickSubmit: function(options, guid)
{
return { request: Enum.Request.RemoveServer, guid: postdata.id };
self.websocket.sendGuid(Enum.Request.RemoveServer, guid);
return true;
}
});

Expand Down Expand Up @@ -212,19 +217,24 @@ var XGBase = Class.create(
hidegrid: false
}).navGrid('#channels_pager', {edit:false, search:false}, {},
{
mtype: "GET",
url: "/",
serializeEditData: function (postdata)
processing: true,
reloadAfterSubmit: false,
savekey: [true,13],
closeOnEscape: true,
closeAfterAdd: true,
onclickSubmit: function (options, obj)
{
return { request: Enum.Request.AddChannel, name: postdata.Name, guid: self.idServer };
self.websocket.sendNameGuid(Enum.Request.AddChannel, obj.Name, self.idServer);
return {};
}
},
{
mtype: "GET",
url: "/",
serializeDelData: function (postdata)
processing: true,
closeOnEscape: true,
onclickSubmit: function(options, guid)
{
return { request: Enum.Request.RemoveChannel, guid: postdata.id };
self.websocket.sendGuid(Enum.Request.RemoveChannel, guid);
return true;
}
});

Expand Down
5 changes: 4 additions & 1 deletion Server.Plugin.General.Webserver/Resources/js/xg/translate.js
Expand Up @@ -21,7 +21,10 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//

var translatedArray = {};
if (translatedArray == undefined)
{
var translatedArray = {};
}

/**
* @param {String} string
Expand Down
52 changes: 23 additions & 29 deletions Server.Plugin.General.Webserver/Resources/js/xg/websocket.js
Expand Up @@ -29,10 +29,10 @@ var XGWebsocket = Class.create(

this.cookie = cookie;

this.onConnected = 0;
this.onDisconnected = 0;
this.onMessageReceived = 0;
this.onError = 0;
this.onConnected = function () {};
this.onDisconnected = function () {};
this.onMessageReceived = function (msg) {};
this.onError = function (exception) {};

this.Password = password;

Expand All @@ -44,45 +44,30 @@ var XGWebsocket = Class.create(
{
self.state = self.socket.readyState;

if (self.onConnected != 0)
{
self.onConnected();
}
}
self.onConnected();
};
this.socket.onmessage = function (msg)
{
if (self.onMessageReceived != 0)
{
self.onMessageReceived(JSON.parse(msg.data));
}
}
self.onMessageReceived(JSON.parse(msg.data));
};
this.socket.onclose = function ()
{
self.state = self.socket.readyState;

if (self.onDisconnected != 0)
{
self.onDisconnected();
}
}
self.onDisconnected();
};
this.socket.onerror = function ()
{
self.state = self.socket.readyState;

if (self.onError != 0)
{
self.onError();
}
}
self.onError("");
};
}
catch (exception)
{
this.state = self.socket.readyState;

if (self.onError != 0)
{
self.onError(exception);
}
self.onError(exception);
}
},

Expand All @@ -91,7 +76,7 @@ var XGWebsocket = Class.create(
return {
"Password": this.Password,
"Type": Type,
"IgnoreOfflineBots": this.cookie.getCookie("show_offline_bots", false)
"IgnoreOfflineBots": this.cookie.getCookie("show_offline_bots", false) == "1"
};
},

Expand All @@ -118,6 +103,15 @@ var XGWebsocket = Class.create(
return this.sendRequest(request);
},

sendNameGuid: function(type, name, guid)
{
var request = this.buildRequest(type);
request.Name = name;
request.Guid = guid;

return this.sendRequest(request);
},

sendRequest: function(request)
{
if (this.state == WebSocket.OPEN)
Expand Down
1 change: 1 addition & 0 deletions Server.Plugin.General.Webserver/Webserver/FileLoader.cs
Expand Up @@ -51,6 +51,7 @@ public class FileLoader
"external/jquery.flot",
"external/jquery.flot.axislabels",
"external/jquery.jqGrid.min",
"external/jquery-timing.min",
"external/jquery-ui.min",
"external/json2.min",
"external/sha256",
Expand Down
1 change: 1 addition & 0 deletions Server.Plugin.General.Webserver/Websocket/Response.cs
Expand Up @@ -39,6 +39,7 @@ public enum Types
ObjectAdded = 1,
ObjectRemoved = 2,
ObjectChanged = 3,
ObjectEnabledChanged = 4,

#endregion

Expand Down
35 changes: 0 additions & 35 deletions Server.Plugin.General.Webserver/Websocket/Response/Object.cs

This file was deleted.

37 changes: 0 additions & 37 deletions Server.Plugin.General.Webserver/Websocket/Response/Objects.cs

This file was deleted.

33 changes: 0 additions & 33 deletions Server.Plugin.General.Webserver/Websocket/Response/Snapshot.cs

This file was deleted.

35 changes: 0 additions & 35 deletions Server.Plugin.General.Webserver/Websocket/Response/Snapshots.cs

This file was deleted.

35 changes: 0 additions & 35 deletions Server.Plugin.General.Webserver/Websocket/Response/Statistics.cs

This file was deleted.

0 comments on commit 7466429

Please sign in to comment.