=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/index.html' --- src/com/goldencode/p2j/ui/client/driver/web/index.html 2016-02-24 22:48:55 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/index.html 2016-03-03 18:33:11 +0000 @@ -10,6 +10,7 @@ + === added file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.constants.js' --- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.constants.js 1970-01-01 00:00:00 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.constants.js 2016-03-03 19:11:27 +0000 @@ -0,0 +1,192 @@ +/* +** Module : p2j.constants.js +** Abstract : The common constants. +** +** Copyright (c) 2014-2016, Golden Code Development Corporation. +** ALL RIGHTS RESERVED. Use is subject to license terms. +** +** Golden Code Development Corporation +** CONFIDENTIAL +** +** -#- -I- --Date-- ------------------------------Description---------------------------------- +** 001 SBI 20160303 Added messages types from the source module WebClientMessageTypes.java. +*/ + +"use strict"; + +/** Message that the web page has finished loading/initializing. */ +var MSG_PAGE_LOADED = 0xFF; + +/** Progress compatible keyboard message. */ +var MSG_KEY = 0x01; + +/** Virtual VT100 terminal keyboard message. */ +var MSG_KEY_VT100 = 0x02; + +/** Paste message. */ +var MSG_PASTE = 0x03; + +/** Contents from the clipboard. */ +var MSG_CLIPBOARD_CONTENTS = 0x04; + +/** Web client is requesting the current selection text. */ +var MSG_CLIPBOARD_PREPARE = 0x05; + +/** Web client is sending computed paragraph height. */ +var MSG_SENT_PAR_HEIGHT = 0x06; + +/** Web client is sending computed text height. */ +var MSG_SENT_TEXT_HEIGHT = 0x07; + +/** Web client is sending computed text width. */ +var MSG_SENT_TEXT_WIDTH = 0x08; + +/** Web client is sending computed font height. */ +var MSG_SENT_FONT_HEIGHT = 0x09; + +/** Web client is sending computed font widths. */ +var MSG_SENT_FONT_WIDTHS = 0x0A; + +/** Web client is informing the font has been created. */ +var MSG_DONE_CREATE_FONT = 0x0B; + +/** Web client is informing the font has been derived. */ +var MSG_DONE_DERIVE_FONT = 0x0C; + +/** Web client is informing of a mouse event. */ +var MSG_MOUSE_EVENT = 0x0D; + +/** Web client is informing of new window location. */ +var MSG_SET_WINDOW_LOC = 0x0E; + +/** Web client is informing of new top window. */ +var MSG_WINDOW_ACTIVATED = 0x0F; + +/** Web client is informing of new window iconification state. */ +var MSG_WINDOW_ICONIFY = 0x10; + +/** Web client is informing of new window location/dimension after resize. */ +var MSG_WINDOW_RESIZED = 0x11; + +/** Web client is informing it finished removing the hashes. */ +var MSG_DRAW_HASH_REMOVED = 0x12; + +/** Clear screen message. */ +var MSG_CLEAR = 0x80; + +/** Draw text on screen. */ +var MSG_DRAW = 0x81; + +/** Set cursor position. */ +var MSG_CURSOR_POS = 0x82; + +/** Set cursor status. */ +var MSG_CURSOR_STATUS = 0x83; + +/** Beep message. */ +var MSG_BEEP = 0x84; + +/** Quit message. */ +var MSG_QUIT = 0x85; + +/** Switch input processing to virtual VT100 terminal mode. */ +var MSG_VT100 = 0x86; + +/** Request clipboard contents from web client. */ +var MSG_READ_CLIPBOARD = 0x87; + +/** Copy the given text to the web client's clipboard. */ +var MSG_WRITE_CLIPBOARD = 0x88; + +/** Create a new top-level window. */ +var MSG_CREATE_WINDOW = 0x89; + +/** Create a new child window. */ +var MSG_CREATE_CHILD_WINDOW = 0x8A; + +/** Destroy the specified window or child window. */ +var MSG_DESTROY_WINDOW = 0x8B; + +/** Change the visibility for the specified window or child window. */ +var MSG_WINDOW_VISIBILITY = 0x8C; + +/** Ask the client for the paragraph height. */ +var MSG_GET_PAR_HEIGHT = 0x8D; + +/** Ask the client for the text height. */ +var MSG_GET_TEXT_HEIGHT = 0x8E; + +/** Ask the client for the text width. */ +var MSG_GET_TEXT_WIDTH = 0x8F; + +/** Ask the client for the font height. */ +var MSG_GET_FONT_HEIGHT = 0x90; + +/** Ask the client for the font widths. */ +var MSG_GET_FONT_WIDTHS = 0x91; + +/** Ask the client to create a font. */ +var MSG_CREATE_FONT = 0x92; + +/** Ask the client to derive a font. */ +var MSG_DERIVE_FONT = 0x93; + +/** Set the cursor style. */ +var MSG_SET_CURSOR_STYLE = 0x94; + +/** Restack the z-order of all windows. */ +var MSG_RESTACK_WINDOWS = 0x95; + +/** Send the mouse-aware widget details. */ +var PROCESS_MOUSE_WIDGETS = 0x96; + +/** Disable/enable mouse event processing. */ +var CAPTURE_MOUSE = 0x97; + +/** Disable/enable OS event processing. */ +var ENABLE_OS_EVENTS = 0x98; + +/** Window state changed event. */ +var SET_ICONIFICATION_STATE = 0x99; + +/** Resizeable widget. */ +var SET_RESIZEABLE_WINDOW = 0x9A; + +/** Notifies the client about the current selection. */ +var MSG_CURRENT_SELECTION = 0x9B; + +/** Requests the client to move a window to the top of the z-order. */ +var MSG_MOVE_TO_TOP = 0x9C; + +/** Requests the client to move a window to the bottom of the z-order. */ +var MSG_MOVE_TO_BOTTOM = 0x9D; + +/** Change the sensitivity for the specified window or child window. */ +var MSG_WINDOW_SENSITIVITY = 0x9E; + +/** Register hoverable widget */ +var MSG_REGISTER_HOVERABLE_WIDGET = 0x9F; + +/** Deregister widget */ +var MSG_DEREGISTER_WIDGET = 0xA0; + +/** Set mouse pointer */ +var MSG_SET_MOUSE_PTR = 0xA1; + +/** Lock mouse pointer */ +var MSG_LOCK_MOUSE_PTR = 0xA2; + +/** Lock mouse pointer */ +var MSG_SET_WAIT_STATE = 0xA3; + +/** Requests the client if the target font is installed. */ +var MSG_IS_FONT_INSTALLED = 0xF1; + +/** Inform the javascript side to remove the list of expired hashes. */ +var MSG_REMOVE_EXPIRED_HASH = 0xF2; + +/** Wraps the large message from the client to the sequence of this partial type messages. */ +var MSG_PARTIAL = 0xFE; + +/** Ping/Pong messages. */ +var MSG_PING_PONG = 0xFC; === modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js' --- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2016-03-02 17:36:26 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2016-03-03 19:16:50 +0000 @@ -45,7 +45,7 @@ ** client-side). ** SBI 20160225 Implemented MSG_PARTIAL, added MSG_PING_PONG and idle/connectivity timers, ** added the default "Stay on page or Leave page" dialog if a user tries to close -** or to refresh the web application page. +** or to refresh the web application page, added named message types constants. */ "use strict"; @@ -279,7 +279,7 @@ me.sendPartialMessage = function(data, position, limit, payloadLength, msgId, isLast) { var msg = new Uint8Array(payloadLength + 10); - msg[0] = 0xFE; + msg[0] = MSG_PARTIAL; me.writeInt32BinaryMessage(msg, 1, msgId); msg[5] = isLast ? 0 : 1; me.writeInt32BinaryMessage(msg, 6, payloadLength); @@ -310,7 +310,7 @@ var msg = new Uint8Array(7); // message type - msg[0] = 0x0f; + msg[0] = MSG_WINDOW_ACTIVATED; // 1. the window ID me.writeInt32BinaryMessage(msg, 1, wid); @@ -335,7 +335,7 @@ var msg = new Uint8Array(6); // message type - msg[0] = 0x10; + msg[0] = MSG_WINDOW_ICONIFY; // 0. the window ID me.writeInt32BinaryMessage(msg, 1, wid); @@ -652,50 +652,50 @@ switch (message[0]) { - case 0x80: + case MSG_CLEAR: // clear screen p2j.screen.clear(); break; - case 0x81: + case MSG_DRAW: p2j.screen.drawRectangles(message); var t2 = (new Date()).getTime(); console.log(callNo + ":" + drawNo + " draw: " + message.length + " done in " + (t2 - t1)); return; - case 0x82: + case MSG_CURSOR_POS: // set cursor position p2j.screen.setCursorPosition(message[1], message[2]); break; - case 0x83: + case MSG_CURSOR_STATUS: // show cursor p2j.screen.setCursorStatus(message[1]); break; - case 0x84: + case MSG_BEEP: // message beep p2j.sound.beep(); break; - case 0x85: + case MSG_QUIT: // quit doRedirectToLoginPage(); break; - case 0x86: + case MSG_VT100: // switch mode p2j/vt100 p2j.keyboard.vt100 = (message[1] == 0) ? false : true; break; - case 0x87: + case MSG_READ_CLIPBOARD: // server-driven request for clipboard contents p2j.clipboard.sendClipboardContents(); break; - case 0x88: + case MSG_WRITE_CLIPBOARD: // The clipboard is changed. var text = me.readStringBinaryMessage(message, 1); p2j.clipboard.writeClipboard(text); break; - case 0x89: + case MSG_CREATE_WINDOW: // create a top-level window with the given id var id = me.readInt32BinaryMessage(message, 1); p2j.screen.createWindow(id); break; - case 0x8A: + case MSG_CREATE_CHILD_WINDOW: // create a child window with the given id, owner and title var offset = 1; var overlay = (message[offset++] == 1); @@ -706,7 +706,7 @@ var title = me.readStringBinaryMessage(message, offset); p2j.screen.createChildWindow(id, owner, title, overlay); break; - case 0x8B: + case MSG_DESTROY_WINDOW: // destroy top-level or child window var id = me.readInt32BinaryMessage(message, 1); var numberImages = me.readInt32BinaryMessage(message, 5); @@ -717,7 +717,7 @@ } p2j.screen.destroyWindow(id, images); break; - case 0x8C: + case MSG_WINDOW_VISIBILITY: // change visibility for top-level or child window var id = me.readInt32BinaryMessage(message, 1); var visible = message[5] === 0 ? false : true; @@ -725,7 +725,7 @@ break; // font and metrics related requests - case 0x8D: + case MSG_GET_PAR_HEIGHT: // paragraph height var offset = 1; @@ -752,9 +752,9 @@ 0, maxWidth); - me.sendInt16BinaryMessage(0x06, msgId, pheight); + me.sendInt16BinaryMessage(MSG_SENT_PAR_HEIGHT, msgId, pheight); break; - case 0x8E: + case MSG_GET_TEXT_HEIGHT: // text height var offset = 1; @@ -772,9 +772,9 @@ var theight = p2j.fonts.getTextHeight(font, text); - me.sendInt8BinaryMessage(0x07, msgId, theight); + me.sendInt8BinaryMessage(MSG_SENT_TEXT_HEIGHT, msgId, theight); break; - case 0x8F: + case MSG_GET_TEXT_WIDTH: // text width var offset = 1; @@ -793,9 +793,9 @@ var twidth = p2j.fonts.getTextWidth(font, text); - me.sendInt16BinaryMessage(0x08, msgId, twidth); + me.sendInt16BinaryMessage(MSG_SENT_TEXT_WIDTH, msgId, twidth); break; - case 0x90: + case MSG_GET_FONT_HEIGHT: // font height var offset = 1; @@ -808,9 +808,9 @@ var fheight = p2j.fonts.getFontHeight(font); - me.sendInt8BinaryMessage(0x09, msgId, fheight); + me.sendInt8BinaryMessage(MSG_SENT_FONT_HEIGHT, msgId, fheight); break; - case 0x91: + case MSG_GET_FONT_WIDTHS: // font widths var offset = 1; @@ -823,9 +823,9 @@ var fwidths = p2j.fonts.getFontWidths(font); - me.sendByteArrayBinaryMessage(0x0A, msgId, fwidths); + me.sendByteArrayBinaryMessage(MSG_SENT_FONT_WIDTHS, msgId, fwidths); break; - case 0x92: + case MSG_CREATE_FONT: // create font var offset = 1; @@ -865,9 +865,9 @@ var fontId = p2j.fonts.createFont(font, name, size, style, b64font); - me.sendInt32BinaryMessage(0x0B, msgId, fontId); + me.sendInt32BinaryMessage(MSG_DONE_CREATE_FONT, msgId, fontId); break; - case 0x93: + case MSG_DERIVE_FONT: // derive font var offset = 1; @@ -880,16 +880,16 @@ p2j.fonts.deriveFont(font); - me.sendInt8BinaryMessage(0x0C, msgId, 1); + me.sendInt8BinaryMessage(MSG_DONE_DERIVE_FONT, msgId, 1); break; - case 0x94: + case MSG_SET_CURSOR_STYLE: // console.log("setCursorStyle"); // set cursor style var styleId = me.readInt32BinaryMessage(message, 1); var wid = me.readInt32BinaryMessage(message, 5); p2j.screen.setCursorStyle(styleId, wid); break; - case 0x95: + case MSG_RESTACK_WINDOWS: // restack windows var num = me.readInt32BinaryMessage(message, 1); var winids = []; @@ -899,7 +899,7 @@ } p2j.screen.restackZOrderEntries(winids); break; - case 0x96: + case PROCESS_MOUSE_WIDGETS: // register/deregister widgets for mouse actions var offset = 1; @@ -1064,16 +1064,16 @@ } break; - case 0x97: + case CAPTURE_MOUSE: // enable/disable mouse events p2j.screen.captureMouseEvents(message[1] == 1); break; - case 0x98: + case ENABLE_OS_EVENTS: // enable/disable OS events var wid = me.readInt32BinaryMessage(message, 1); p2j.screen.enableOsEvents(wid, message[5] == 1); break; - case 0x99: + case SET_ICONIFICATION_STATE: // set window iconification state var offset = 1; @@ -1095,7 +1095,7 @@ } break; - case 0x9A: + case SET_RESIZEABLE_WINDOW: // resizeable window var offset = 1; @@ -1134,26 +1134,26 @@ } break; - case 0x9B: + case MSG_CURRENT_SELECTION: // current editors selection is changed var text = me.readStringBinaryMessage(message, 1); p2j.clipboard.setSelection(text); break; - case 0x9C: + case MSG_MOVE_TO_TOP: var id = me.readInt32BinaryMessage(message, 1); p2j.screen.moveToTop(id); break; - case 0x9D: + case MSG_MOVE_TO_BOTTOM: var id = me.readInt32BinaryMessage(message, 1); p2j.screen.moveToBottom(id); break; - case 0x9E: + case MSG_WINDOW_SENSITIVITY: // change sensitivity for top-level or child window var id = me.readInt32BinaryMessage(message, 1); var enabled = message[5] === 0 ? false : true; p2j.screen.setWindowEnabled(id, enabled); break; - case 0x9F: + case MSG_REGISTER_HOVERABLE_WIDGET: // console.log("registerHoverableWidget"); var offset = 1; var wid = me.readInt32BinaryMessage(message, offset); @@ -1189,7 +1189,7 @@ console.log("unknown window: %s", wid); } break; - case 0xA0: + case MSG_DEREGISTER_WIDGET: // console.log("deregisterWidget"); var offset = 1; var wid = me.readInt32BinaryMessage(message, offset); @@ -1205,7 +1205,7 @@ console.log("unknown window: %s", wid); } break; - case 0xA1: + case MSG_SET_MOUSE_PTR: // console.log("setMousePtr"); var offset = 1; var wid = me.readInt32BinaryMessage(message, offset); @@ -1223,7 +1223,7 @@ console.log("unknown window: %s", wid); } break; - case 0xA2: + case MSG_LOCK_MOUSE_PTR: // console.log("lockMousePointer"); var offset = 1; var wid = me.readInt32BinaryMessage(message, offset); @@ -1231,13 +1231,13 @@ var ptr = me.readMousePtrBinaryMessage(message, offset); p2j.screen.lockMousePointer(wid, ptr); break; - case 0xA3: + case MSG_SET_WAIT_STATE: // console.log("setWaitState"); var offset = 1; var isWaitState = message[offset] == 1; p2j.screen.setWaitState(isWaitState); break; - case 0xF1: + case MSG_IS_FONT_INSTALLED: // font is installed var offset = 1; @@ -1251,9 +1251,9 @@ var result = p2j.fonts.isFontInstalled(fontName); - me.sendInt8BinaryMessage(0xF1, msgId, result ? 1 : 0); + me.sendInt8BinaryMessage(MSG_IS_FONT_INSTALLED, msgId, result ? 1 : 0); break; - case 0xF2: + case MSG_REMOVE_EXPIRED_HASH: // remove hashes var offset = 1; @@ -1295,9 +1295,9 @@ } } - me.sendInt8BinaryMessage(0x12, msgId, 1); + me.sendInt8BinaryMessage(MSG_DRAW_HASH_REMOVED, msgId, 1); break; - case 0xFC: + case MSG_PING_PONG: // ping/pong server answer if (pingPongWatcher) { @@ -1433,7 +1433,7 @@ { // reload use case doRedirectToLoginPage(); - me.sendNotification(0x85); + me.sendNotification(MSG_QUIT); } else { @@ -1458,7 +1458,7 @@ { // binary messages var message = new Uint8Array(data); - var isDrawing = message[0] === 0x81; + var isDrawing = message[0] === MSG_DRAW; if (isDrawing) { p2j.displayWaitCursor(); @@ -1640,7 +1640,7 @@ function ping() { //send Ping/Pong message - me.sendNotification(0xFC); + me.sendNotification(MSG_PING_PONG); if (pingPongWatcher) { clearTimeout(pingPongWatcher);