Webclient overhaul (#2735)
Migrate from protobuf.js 5.x to 6.x (remove long.js and bytebuffer.js) Upgrade jQuery from 1.x to 3.x Upgrade jQueryUI to 1.12.x Use minimized version of js libraries Disable debug messages Fix default value for Event_RoomSay’s RoomMessageType field
|
@ -6,8 +6,9 @@ message Event_RoomSay {
|
|||
optional Event_RoomSay ext = 1002;
|
||||
}
|
||||
enum RoomMessageType {
|
||||
Welcome = 1; // rooms welcome message
|
||||
ChatHistory = 2; // rooms chat history message
|
||||
UserMessage = 0; // user message
|
||||
Welcome = 1; // rooms welcome message
|
||||
ChatHistory = 2; // rooms chat history message
|
||||
}
|
||||
optional string name = 1;
|
||||
optional string message = 2;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<title>Cockatrice web client</title>
|
||||
<link rel="shortcut icon" href="imgs/cockatrice.png" />
|
||||
<link rel="stylesheet" href="js/jquery-ui-1.11.4.css">
|
||||
<link rel="stylesheet" href="js/jquery-ui-1.12.1.min.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
@ -75,11 +75,9 @@ Loading cockatrice web client...
|
|||
|
||||
</div>
|
||||
|
||||
<script src="js/jquery-1.11.3.js"></script>
|
||||
<script src="js/jquery-ui-1.11.4.js"></script>
|
||||
<script src="js/long.js"></script>
|
||||
<script src="js/bytebuffer.js"></script>
|
||||
<script src="js/protobuf.js"></script>
|
||||
<script src="js/jquery-3.2.1.min.js"></script>
|
||||
<script src="js/jquery-ui-1.12.1.min.js"></script>
|
||||
<script src="js/protobuf-6.7.0.min.js"></script>
|
||||
<script src="webclient.js"></script>
|
||||
|
||||
<script>
|
||||
|
@ -216,7 +214,7 @@ Loading cockatrice web client...
|
|||
}
|
||||
|
||||
var options = {
|
||||
"debug": true,
|
||||
"debug": false,
|
||||
"autojoinrooms" : true,
|
||||
"host": host,
|
||||
"port": port,
|
||||
|
@ -284,7 +282,7 @@ Loading cockatrice web client...
|
|||
switch(key)
|
||||
{
|
||||
case 'avatarBmp':
|
||||
$('#userinfo').prepend("<img id='avatar' src='data:image/JPEG;base64," + value.toBase64() + "' /><br/>");
|
||||
$('#userinfo').prepend("<img id='avatar' src='data:image/JPEG;base64," + btoa(String.fromCharCode.apply(null, value)) + "' /><br/>");
|
||||
break;
|
||||
case 'accountageSecs':
|
||||
$('#userinfo').append('Registered since: ' + timeAgoToInterval(value) + '<br/>');
|
||||
|
|
Before Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 207 B |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 328 B |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 4.4 KiB |
BIN
webclient/js/images/ui-icons_444444_256x240.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
webclient/js/images/ui-icons_555555_256x240.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
webclient/js/images/ui-icons_777620_256x240.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
webclient/js/images/ui-icons_777777_256x240.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
webclient/js/images/ui-icons_cc0000_256x240.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
10351
webclient/js/jquery-1.11.3.js
vendored
4
webclient/js/jquery-3.2.1.min.js
vendored
Normal file
1225
webclient/js/jquery-ui-1.11.4.css
vendored
16617
webclient/js/jquery-ui-1.11.4.js
vendored
7
webclient/js/jquery-ui-1.12.1.min.css
vendored
Normal file
13
webclient/js/jquery-ui-1.12.1.min.js
vendored
Normal file
1220
webclient/js/long.js
10
webclient/js/protobuf-6.7.0.min.js
vendored
Normal file
|
@ -26,8 +26,6 @@ var WebClient = {
|
|||
keepalive: 5000
|
||||
},
|
||||
|
||||
protobuf : null,
|
||||
builder : null,
|
||||
pb : null,
|
||||
pbfiles : [
|
||||
// commands
|
||||
|
@ -53,14 +51,13 @@ var WebClient = {
|
|||
|
||||
initialize : function()
|
||||
{
|
||||
this.protobuf = dcodeIO.ProtoBuf;
|
||||
this.builder = this.protobuf.newBuilder({ convertFieldsToCamelCase: true });
|
||||
|
||||
$.each(this.pbfiles, function(index, fileName) {
|
||||
WebClient.protobuf.loadProtoFile(fileName, WebClient.builder);
|
||||
this.pb = new protobuf.Root({
|
||||
convertFieldsToCamelCase: true,
|
||||
});
|
||||
|
||||
this.pb.load(this.pbfiles, {
|
||||
keepCase: false
|
||||
});
|
||||
|
||||
this.pb = this.builder.build();
|
||||
|
||||
this.initialized=true;
|
||||
},
|
||||
|
@ -96,7 +93,7 @@ var WebClient = {
|
|||
this.pendingCommands[this.cmdId] = callback;
|
||||
|
||||
if (this.socket.readyState == WebSocket.OPEN) {
|
||||
this.socket.send(cmd.toArrayBuffer());
|
||||
this.socket.send(WebClient.pb.CommandContainer.encode(cmd).finish());
|
||||
if(this.options.debug)
|
||||
console.log("Sent: " + cmd.toString());
|
||||
} else {
|
||||
|
@ -107,7 +104,7 @@ var WebClient = {
|
|||
|
||||
sendRoomCommand : function(roomId, roomCmd, callback)
|
||||
{
|
||||
var cmd = new WebClient.pb.CommandContainer({
|
||||
var cmd = WebClient.pb.CommandContainer.create({
|
||||
"roomId" : roomId,
|
||||
"roomCommand" : [ roomCmd ]
|
||||
});
|
||||
|
@ -116,7 +113,7 @@ var WebClient = {
|
|||
|
||||
sendSessionCommand : function(ses, callback)
|
||||
{
|
||||
var cmd = new WebClient.pb.CommandContainer({
|
||||
var cmd = WebClient.pb.CommandContainer.create({
|
||||
"sessionCommand" : [ ses ]
|
||||
});
|
||||
WebClient.sendCommand(cmd, callback);
|
||||
|
@ -141,9 +138,9 @@ var WebClient = {
|
|||
}
|
||||
|
||||
// send a ping
|
||||
var CmdPing = new WebClient.pb.Command_Ping();
|
||||
var CmdPing = WebClient.pb.Command_Ping.create();
|
||||
|
||||
var sc = new WebClient.pb.SessionCommand({
|
||||
var sc = WebClient.pb.SessionCommand.create({
|
||||
".Command_Ping.ext" : CmdPing
|
||||
});
|
||||
|
||||
|
@ -157,21 +154,26 @@ var WebClient = {
|
|||
|
||||
doLogin : function()
|
||||
{
|
||||
var CmdLogin = new WebClient.pb.Command_Login({
|
||||
var CmdLogin = WebClient.pb.Command_Login.create({
|
||||
"userName" : this.options.user,
|
||||
"password" : this.options.pass,
|
||||
"clientid" : this.guid(),
|
||||
"clientver" : "webclient-0.2 (2016-08-03)",
|
||||
"clientver" : "webclient-0.3 (2017-05-26)",
|
||||
"clientfeatures" : [
|
||||
"client_id",
|
||||
"client_ver",
|
||||
"feature_set",
|
||||
"room_chat_history",
|
||||
"client_warnings"
|
||||
"client_warnings",
|
||||
/* unimplemented features */
|
||||
"forgot_password",
|
||||
"idle_client",
|
||||
"mod_log_lookup",
|
||||
"user_ban_history"
|
||||
]
|
||||
});
|
||||
|
||||
var sc = new WebClient.pb.SessionCommand({
|
||||
var sc = WebClient.pb.SessionCommand.create({
|
||||
".Command_Login.ext" : CmdLogin
|
||||
});
|
||||
|
||||
|
@ -227,9 +229,9 @@ var WebClient = {
|
|||
|
||||
doListRooms : function()
|
||||
{
|
||||
var CmdListRooms = new WebClient.pb.Command_ListRooms();
|
||||
var CmdListRooms = WebClient.pb.Command_ListRooms.create();
|
||||
|
||||
var sc = new WebClient.pb.SessionCommand({
|
||||
var sc = WebClient.pb.SessionCommand.create({
|
||||
".Command_ListRooms.ext" : CmdListRooms
|
||||
});
|
||||
|
||||
|
@ -289,11 +291,11 @@ var WebClient = {
|
|||
$.each(roomsList, function(index, room) {
|
||||
if(room.autoJoin)
|
||||
{
|
||||
var CmdJoinRoom = new WebClient.pb.Command_JoinRoom({
|
||||
var CmdJoinRoom = WebClient.pb.Command_JoinRoom.create({
|
||||
"roomId" : room.roomId
|
||||
});
|
||||
|
||||
var sc = new WebClient.pb.SessionCommand({
|
||||
var sc = WebClient.pb.SessionCommand.create({
|
||||
".Command_JoinRoom.ext" : CmdJoinRoom
|
||||
});
|
||||
|
||||
|
@ -395,19 +397,19 @@ var WebClient = {
|
|||
this.socket.onmessage = function(event) {
|
||||
//console.log("Received " + event.data.byteLength + " bytes");
|
||||
|
||||
var uint8msg = new Uint8Array(event.data);
|
||||
try {
|
||||
var msg = WebClient.pb.ServerMessage.decode(event.data);
|
||||
var msg = WebClient.pb.ServerMessage.decode(uint8msg);
|
||||
if(WebClient.options.debug)
|
||||
console.log(msg);
|
||||
} catch (err) {
|
||||
console.log("Processing failed:", err);
|
||||
if(WebClient.options.debug)
|
||||
{
|
||||
var view = new Uint8Array(event.data);
|
||||
var str = "";
|
||||
for(var i = 0; i < view.length; i++)
|
||||
for(var i = 0; i < uint8msg.length; i++)
|
||||
{
|
||||
str += String.fromCharCode(view[i]);
|
||||
str += String.fromCharCode(uint8msg[i]);
|
||||
}
|
||||
console.log(str);
|
||||
}
|
||||
|
@ -442,11 +444,11 @@ var WebClient = {
|
|||
},
|
||||
|
||||
roomSay : function(roomId, msg) {
|
||||
var CmdRoomSay = new WebClient.pb.Command_RoomSay({
|
||||
var CmdRoomSay = WebClient.pb.Command_RoomSay.create({
|
||||
"message" : msg
|
||||
});
|
||||
|
||||
var sc = new WebClient.pb.RoomCommand({
|
||||
var sc = WebClient.pb.RoomCommand.create({
|
||||
".Command_RoomSay.ext" : CmdRoomSay
|
||||
});
|
||||
|
||||
|
|