Ejemplo n.º 1
0
  private void initChat() {
    if (chatController != null) {
      return;
    }

    chatController = new ChatController();
    chatController.setListener(this);
    chatController.setAuthToken(broadcastController.getAuthToken());

    if (!chatController.connect(username)) {
      chatController = null;
    }
  }
Ejemplo n.º 2
0
  private void handleInput() {
    while (Keyboard.next()) {
      if (Keyboard.isRepeatEvent()) {
        continue;
      }

      if (!Keyboard.getEventKeyState()) {
        continue;
      }

      if (Keyboard.getEventKey() == Keyboard.KEY_A) {
        broadcastController.requestAuthToken(username, password);
      } else if (Keyboard.getEventKey() == Keyboard.KEY_S) {
        broadcastController.setStreamInfo(username, "Java Game", "Fun times");
      } else if (Keyboard.getEventKey() == Keyboard.KEY_P) {
        if (broadcastController.getIsPaused()) {
          broadcastController.resumeBroadcasting();
        } else {
          broadcastController.pauseBroadcasting();
        }
      } else if (Keyboard.getEventKey() == Keyboard.KEY_SPACE) {
        if (broadcastController.getIsBroadcasting()) {
          broadcastController.stopBroadcasting();
        } else {
          VideoParams videoParams =
              broadcastController.getRecommendedVideoParams(
                  Display.getDisplayMode().getWidth(),
                  Display.getDisplayMode().getHeight(),
                  broadcastFramesPerSecond);
          videoParams.verticalFlip = true;

          broadcastController.startBroadcasting(videoParams);
        }
      } else if (Keyboard.getEventKey() == Keyboard.KEY_R) {
        broadcastController.runCommercial();
      } else if (Keyboard.getEventKey() == Keyboard.KEY_I) {
        if (ingestTester != null) {
          broadcastController.cancelIngestTest();
          ingestTester = null;
        } else {
          ingestTester = broadcastController.startIngestTest();
          ingestTester.setListener(this);
        }
      } else if (Keyboard.getEventKey() == Keyboard.KEY_G) {
        broadcastController.requestGameNameList("final");
      } else if (Keyboard.getEventKey() == Keyboard.KEY_1) {
        broadcastController.sendActionMetaData(
            "TestAction",
            broadcastController.getCurrentBroadcastTime(),
            "Something cool happened",
            "{ \"MyValue\" : \"42\" }");
      } else if (Keyboard.getEventKey() == Keyboard.KEY_2) {
        if (metaDataSpanSequenceId == -1) {
          metaDataSpanSequenceId =
              broadcastController.startSpanMetaData(
                  "TestSpan",
                  broadcastController.getCurrentBroadcastTime(),
                  "Something cool just started happening",
                  "{ \"MyValue\" : \"42\" }");
        } else {
          broadcastController.endSpanMetaData(
              "TestSpan",
              broadcastController.getCurrentBroadcastTime(),
              metaDataSpanSequenceId,
              "Something cool just stopped happening",
              "{ \"MyValue\" : \"42\" }");
          metaDataSpanSequenceId = -1;
        }
      } else if (Keyboard.getEventKey() == Keyboard.KEY_C) {
        if (chatController != null) {
          if (chatController.getIsConnected()) {
            chatController.disconnect();
          } else {
            chatController.connect(username);
          }
        }
      } else if (Keyboard.getEventKey() == Keyboard.KEY_V) {
        if (chatController != null) {
          if (chatController.getIsConnected()) {
            chatController.disconnect();
          } else {
            chatController.connectAnonymous(username);
          }
        }
      } else if (Keyboard.getEventKey() == Keyboard.KEY_M) {
        if (chatController != null) {
          if (chatController.getIsConnected()) {
            chatController.sendChatMessage("Test chat message: " + System.currentTimeMillis());
          }
        }
      }
    }
  }