Package mosync.lualiveeditor.MessageQueue

Examples of mosync.lualiveeditor.MessageQueue.Message


  private void serverMessageLoop()
  {
    while (mRunning)
    {
      Message message = mServerInBox.waitForMessage();

      if ("ClientConnectionCreated".equals(message.getMessage()))
      {
        // Get connection object.
        ClientConnection connection = (ClientConnection) message.getObject();

        // Inform user that a new connection is opened.
        mMainWindow.showMessage("Client connected: " + connection.getHostName());

        // Add connection.
        mClientConnections.add(connection);

        // Start connection thread.
        connection.start();
      }
      else if ("ClientConnectionClosed".equals(message.getMessage()))
      {
        ClientConnection connection = (ClientConnection) message.getObject();
        mClientConnections.remove(connection);

        // Inform user that a client connection is closed.
        mMainWindow.showMessage("Client has disconnected: " + connection.getHostName());
      }
      else if ("CommandEvalLua".equals(message.getMessage()))
      {
        for (ClientConnection connection : mClientConnections)
        {
          connection.postMessage(
            new Message("CommandEvalLua", message.getObject()));
        }
      }
      else if ("CommandSendFile".equals(message.getMessage()))
      {
       
        File file = (File) message.getObject();
        String filePath = FileData.unixPath(file);
        //String rootPath = FileData.basePath(filePath);
       
        Log.i("CommandSendFile");
        Log.i("filePath: " + filePath);
        //Log.i("rootPath: " + rootPath);

        // Collect files (we may have a directory).
        ArrayList<String> files = new FileWalker().collectFiles(filePath);
        mMainWindow.showMessage("Sending " + files.size() + " file(s)");
        Log.i("Number of files to send: " + files.size());

        // Send update message.
        for (ClientConnection connection : mClientConnections)
        {
          //Log.i("Sending CommandSendFile to client connection: " + connection);
          connection.postMessage(
            new Message(
              "CommandSendFile",
              new FileData(filePath, files)));
        }
      }
      // CommandResetClient not used for now.
      else if ("CommandResetClient".equals(message.getMessage()))
      {
        for (ClientConnection connection : mClientConnections)
        {
          connection.postMessage(
            new Message("CommandResetClient", message.getObject()));
        }
      }
      else if ("MessageFromClient".equals(message.getMessage()))
      {
        mMainWindow.showMessage(message.getObject().toString());
      }
      else if ("CommandServerStop".equals(message.getMessage()))
      {
        stopServer();
      }
      // TODO: How is this used?
      else if("ServerAddressReceived".equals(message.getMessage()))
      {
        Log.i("ServerAddressReceived: " + message.getObject());
        mMainWindow.showMessage(message.getObject().toString());
      }
      /*
      else if ("CommandRun".equals(message.getMessage()))
      {
        File runFile = (File) message.getObject();
View Full Code Here


          Socket socket = mServerSocket.accept();
          ClientConnection clientConnection = new ClientConnection(
            socket,
            mServerInBox);
          mServerInBox.postMessage(
            new Message("ClientConnectionCreated", clientConnection));
        }
      }
      catch (IOException ex)
      {
        // This will happen when closing the server socket.
View Full Code Here

            mRunning = false;

            // Post dummy message to out box to ensure the blocking
            // call to the queue returns and the loop is exited.
            mClientOutBox.postMessage(
              new Message("DummyMessage", mClientConnection));

            // Post connection closed message to server.
            mServerInBox.postMessage(
              new Message("ClientConnectionClosed", mClientConnection));
          }
        }
      };
    }
View Full Code Here

      while (mRunning)
      {
        // Wait for message to send in the outgoing box.
        Log.i("Waiting for outgoing message in client connection: " + getHostName());
        Message message = mClientOutBox.waitForMessage();

        if ("CommandResetClient".equals(message.getMessage()))
        {
          // Send reset request to client.

          // Write command integer.
          writeIntToStream(out, COMMAND_RESET);

          // Write the size of the data, this is 0 bytes,
          // since the message contains no data.
          writeIntToStream(out, 0);

          out.flush();
        }
        else if ("CommandEvalLua".equals(message.getMessage()))
        {
          String data = message.getObject().toString();
          sendEvalLua(out, data);
        }
        else if ("CommandSendFile".equals(message.getMessage()))
        {
          sendFile(out, (FileData) message.getObject());
        }
        else if ("CommandCloseClientConnection".equals(message.getMessage()))
        {
          // This will trigger an IOException and close the connection.
          mSocket.close();
          mRunning = false;
        }
View Full Code Here

          case COMMAND_REPLY:
            // Read reply string. The reply starts at byte 8.
            String data = new String(buffer, 8, dataSize, "ISO-8859-1");

            // Post result message to server.
            mServerInBox.postMessage(new Message("MessageFromClient", data));

            break;
        }
      } // while
    }
View Full Code Here

    mWorkspaceTabPane.saveAll();

    String code = Server.FileData.readFileAsString(file);
    if (null != code)
    {
      mServer.postMessage(new Message("CommandEvalLua", code));
    }
  }
View Full Code Here

 
  public void sendFile(File file)
  {
    Log.i("Send File");
    mWorkspaceTabPane.saveAll();
    mServer.postMessage(new Message("CommandSendFile", file));
  }
View Full Code Here

  {
    public void actionPerformed(ActionEvent e)
    {
      if (null != mServer)
      {
        mServer.postMessage(new Message("CommandServerStop", null));
        mServer = null;
      }
    }
View Full Code Here

    {
      Log.i("CommandEvalLua");
      String code = mWorkspaceTabPane.getSelectedText();
      if (null != code)
      {
        mServer.postMessage(new Message("CommandEvalLua", code));
      }
    }
View Full Code Here

    {
      Log.i("CommandEvalLuaAll");
      String code = mWorkspaceTabPane.getSelectedText();
      if (null != code)
      {
        mServer.postMessage(new Message("CommandEvalLuaAll", code));
      }
    }
View Full Code Here

TOP

Related Classes of mosync.lualiveeditor.MessageQueue.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.