Exemple #1
0
 private static void OnClientMessage(string message)
 {
     Console.WriteLine("RECV: " + message);
     Logger.AddInformation("WebSocket: Received message: " + message, (object)null, (Exception)null, (string)null);
     if (!(message == "seb.beforeclose.manual"))
     {
         if (!(message == "seb.beforeclose.quiturl"))
         {
             if (!(message == "seb.input.focus"))
             {
                 // ISSUE: reference to a compiler-generated field
                 if (!(message == "seb.input.blur") || SEBXULRunnerWebSocketServer.OnXulRunnerTextBlur == null)
                 {
                     return;
                 }
                 // ISSUE: reference to a compiler-generated field
                 SEBXULRunnerWebSocketServer.OnXulRunnerTextBlur((object)null, EventArgs.Empty);
             }
             else
             {
                 // ISSUE: reference to a compiler-generated field
                 if (SEBXULRunnerWebSocketServer.OnXulRunnerTextFocus == null)
                 {
                     return;
                 }
                 // ISSUE: reference to a compiler-generated field
                 SEBXULRunnerWebSocketServer.OnXulRunnerTextFocus((object)null, EventArgs.Empty);
             }
         }
         else
         {
             // ISSUE: reference to a compiler-generated field
             if (SEBXULRunnerWebSocketServer.OnXulRunnerQuitLinkClicked == null)
             {
                 return;
             }
             // ISSUE: reference to a compiler-generated field
             SEBXULRunnerWebSocketServer.OnXulRunnerQuitLinkClicked((object)null, EventArgs.Empty);
         }
     }
     else
     {
         // ISSUE: reference to a compiler-generated field
         if (SEBXULRunnerWebSocketServer.OnXulRunnerCloseRequested == null)
         {
             return;
         }
         // ISSUE: reference to a compiler-generated field
         SEBXULRunnerWebSocketServer.OnXulRunnerCloseRequested((object)null, EventArgs.Empty);
     }
 }
        private static void OnClientMessageBinary(byte[] obj)
        {
            // Check if we're running in exam mode already, if yes, then refuse to load a .seb file
            if (SEBClientInfo.examMode)
            {
                Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data is not allowed because it is already running in exam mode, sending command ReconfigureAborted to browser");
                SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted));

                SebWindowsClientMain.LoadingSebFile(false);
                SebWindowsClientForm.ShowReconfigureNotAllowed();
                return;
            }

            HasBeenReconfiguredByMessage = true;
            Logger.AddInformation("Received downloaded Config File data, " + obj.Length + " bytes. Sending command SebFileTransfer to browser");
            SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.SebFileTransfer, true));
            if (SEBClientInfo.SebWindowsClientForm.ReconfigureWithSettings(obj))
            {
                Logger.AddInformation("SEB was successfully reconfigured using the downloaded Config File data");

                // Convert new URL Filter rules to XUL seb2 rules
                // and add Start URL to allowed rules
                SEBURLFilter urlFilter = new SEBURLFilter();
                urlFilter.UpdateFilterRules();

                // Create JSON object with XULRunner parameters to pass to firefox.exe as base64 string
                var    xulRunnerSettings   = DeepClone(SEBSettings.settingsCurrent);
                string XULRunnerParameters = SEBXulRunnerSettings.XULRunnerConfigDictionarySerialize(xulRunnerSettings);

                SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.Reconfigure, new { configBase64 = XULRunnerParameters }));
            }
            else
            {
                Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data failed, sending command ReconfigureAborted to browser");
                SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted));
            }
            HasBeenReconfiguredByMessage = false;
        }
Exemple #3
0
 public static void StartServer()
 {
     if (SEBXULRunnerWebSocketServer.IsRunning && SEBXULRunnerWebSocketServer.Started)
     {
         return;
     }
     if (SEBXULRunnerWebSocketServer.IsRunning)
     {
         for (int index = 0; index < 60 && SEBXULRunnerWebSocketServer.IsRunning; ++index)
         {
             Thread.Sleep(1000);
         }
         if (SEBXULRunnerWebSocketServer.IsRunning)
         {
             int num = (int)SEBMessageBox.Show(SEBUIStrings.alertWebSocketPortBlocked, SEBUIStrings.alertWebSocketPortBlockedMessage, MessageBoxIcon.Hand, MessageBoxButtons.OK, false);
         }
     }
     try
     {
         Logger.AddInformation("Starting WebSocketServer on " + SEBXULRunnerWebSocketServer.ServerAddress, (object)null, (Exception)null, (string)null);
         SEBXULRunnerWebSocketServer.server = new WebSocketServer(SEBXULRunnerWebSocketServer.ServerAddress);
         FleckLog.Level = Fleck.LogLevel.Debug;
         SEBXULRunnerWebSocketServer.server.Start((Action <IWebSocketConnection>)(socket =>
         {
             socket.OnOpen    = (Action)(() => SEBXULRunnerWebSocketServer.OnClientConnected(socket));
             socket.OnClose   = new Action(SEBXULRunnerWebSocketServer.OnClientDisconnected);
             socket.OnMessage = new Action <string>(SEBXULRunnerWebSocketServer.OnClientMessage);
         }));
         Logger.AddInformation("Started WebSocketServer on " + SEBXULRunnerWebSocketServer.ServerAddress, (object)null, (Exception)null, (string)null);
         SEBXULRunnerWebSocketServer.Started = true;
     }
     catch (Exception ex)
     {
         Logger.AddError("Unable to start WebSocketsServer for communication with XULRunner", (object)null, ex, (string)null);
     }
 }