• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.kurento.jsonrpc.JsonUtils的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils类的具体用法?Java JsonUtils怎么用?Java JsonUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonUtils类属于org.kurento.jsonrpc包,在下文中一共展示了JsonUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: performWebRtcNegotiation

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public String performWebRtcNegotiation(final WebSocketSession session, String sdpOffer) {
  log.info("Starting WebRTC negotiation in session {}", sessionId);

  // Subscribe to ICE candidates
  webRtcEndpoint.addOnIceCandidateListener(new EventListener<OnIceCandidateEvent>() {
    @Override
    public void onEvent(OnIceCandidateEvent event) {
      JsonObject response = new JsonObject();
      response.addProperty("id", "iceCandidate");
      response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
      handler.sendMessage(session, new TextMessage(response.toString()));
    }
  });

  // SDP negotiation
  String sdpAnswer = webRtcEndpoint.processOffer(sdpOffer);

  // Gather ICE candidates
  webRtcEndpoint.gatherCandidates();

  return sdpAnswer;
}
 
开发者ID:nubomedia,项目名称:nubomedia-repository-tutorial,代码行数:23,代码来源:UserSession.java


示例2: kmsManager

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public KurentoClientProvider kmsManager() {

  JsonArray kmsUris = getPropertyJson(KMSS_URIS_PROPERTY, KMSS_URIS_DEFAULT, JsonArray.class);
  List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);

  if (kmsWsUris.isEmpty()) {
    throw new IllegalArgumentException(KMSS_URIS_PROPERTY
        + " should contain at least one kms url");
  }

  String firstKmsWsUri = kmsWsUris.get(0);

  if (firstKmsWsUri.equals("autodiscovery")) {
    log.info("Using autodiscovery rules to locate KMS on every pipeline");
    return new AutodiscoveryKurentoClientProvider();
  } else {
    log.info("Configuring Kurento Room Server to use first of the following kmss: " + kmsWsUris);
    return new FixedOneKmsManager(firstKmsWsUri);
  }
}
 
开发者ID:Kurento,项目名称:kurento-room,代码行数:23,代码来源:KurentoRoomServerApp.java


示例3: processEvent

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
private void processEvent(RomEventHandler eventHandler, Request<JsonObject> request) {

    JsonObject params = request.getParams();

    try {
      params = (JsonObject) params.get("value");
    } catch (Exception e) {
      log.trace("Exception processing event: getting value", e);
    }

    String objectRef = params.get(ONEVENT_OBJECT).getAsString();
    String subscription = "";
    if (params.has(ONEVENT_SUBSCRIPTION)) {
      subscription = params.get(ONEVENT_SUBSCRIPTION).getAsString();
    }
    String type = params.get(ONEVENT_TYPE).getAsString();
    JsonObject jsonData = (JsonObject) params.get(ONEVENT_DATA);
    Props data = JsonUtils.fromJson(jsonData, Props.class);

    eventHandler.processEvent(objectRef, subscription, type, data);
  }
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:22,代码来源:RomClientJsonRpcClient.java


示例4: objectToJsonConversion

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void objectToJsonConversion() {

  JsonObject jsonObject = new JsonObject();
  jsonObject.addProperty("prop1", "XXX");
  jsonObject.addProperty("prop2", 33);
  jsonObject.addProperty("prop3", "YYY");
  jsonObject.addProperty("prop4", 5.5f);

  ComplexParam param = JsonUtils.fromJson(jsonObject, ComplexParam.class);

  assertEquals(param.getProp1(), "XXX");
  assertEquals(param.getProp2(), 33);
  assertEquals(param.getProp3(), "YYY");
  assertEquals(param.getProp4(), 5.5f, 0.01);
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:17,代码来源:RomJsonConverterTest.java


示例5: propsToJsonConversion

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void propsToJsonConversion() {

  JsonObject jsonObject = new JsonObject();
  jsonObject.addProperty("prop1", "XXX");
  jsonObject.addProperty("prop2", 33);
  jsonObject.addProperty("prop3", "YYY");
  jsonObject.addProperty("prop4", 5.5f);

  Props props = JsonUtils.fromJson(jsonObject, Props.class);

  assertEquals(props.getProp("prop1"), "XXX");
  assertEquals(props.getProp("prop2"), 33);
  assertEquals(props.getProp("prop3"), "YYY");
  assertEquals(props.getProp("prop4"), 5.5f);
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:17,代码来源:RomJsonConverterTest.java


示例6: jsonToPropsConversion

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void jsonToPropsConversion() {

  Props param = new Props();
  param.add("prop1", "XXX");
  param.add("prop2", 33);
  param.add("prop3", "YYY");
  param.add("prop4", 5.5f);

  JsonObject jsonObject = JsonUtils.toJsonObject(param);

  assertEquals(jsonObject.get("prop1").getAsString(), "XXX");
  assertEquals(jsonObject.get("prop2").getAsInt(), 33);
  assertEquals(jsonObject.get("prop3").getAsString(), "YYY");
  assertEquals(jsonObject.get("prop4").getAsFloat(), 5.5f, 0.01);

}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:18,代码来源:RomJsonConverterTest.java


示例7: requestTest

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void requestTest() {

  Params params = new Params();
  params.param1 = "Value1";
  params.param2 = "Value2";
  params.data = new Data();
  params.data.data1 = "XX";
  params.data.data2 = "YY";

  Request<Params> request = new Request<Params>(1, "method", params);

  String requestJson = JsonUtils.toJsonRequest(request);

  log.debug(requestJson);

  Request<Params> newRequest = JsonUtils.fromJsonRequest(requestJson, Params.class);

  Assert.assertEquals(params.param1, newRequest.getParams().param1);
  Assert.assertEquals(params.param2, newRequest.getParams().param2);
  Assert.assertEquals(params.data.data1, newRequest.getParams().data.data1);
  Assert.assertEquals(params.data.data2, newRequest.getParams().data.data2);

}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:25,代码来源:GenericMessageTest.java


示例8: noResultResponseTest

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void noResultResponseTest() {

  Response<Void> response = new Response<Void>(1);
  response.setSessionId("xxxxxxx");

  String responseJson = response.toString();
  JsonParser parser = new JsonParser();
  JsonObject expected = (JsonObject) parser
      .parse("{\"id\":1,\"result\":{\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}");
  JsonObject result = (JsonObject) parser.parse(responseJson);
  Assert.assertEquals(expected, result);

  log.debug(responseJson);

  Response<Void> newResponse = JsonUtils.fromJsonResponse(responseJson, Void.class);

  // Assert.assertEquals(null, newResponse.getResult());
  Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx");

}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:22,代码来源:SessionIdMessageTest.java


示例9: responseTest

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void responseTest() {

  Data data = new Data();
  data.data1 = "Value1";

  Response<Data> response = new Response<Data>(1, data);
  response.setSessionId("xxxxxxx");

  String responseJson = response.toString();
  Assert.assertEquals(
      "{\"id\":1,\"result\":{\"data1\":\"Value1\",\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}",
      responseJson);

  log.debug(responseJson);

  Response<Data> newResponse = JsonUtils.fromJsonResponse(responseJson, Data.class);

  Assert.assertEquals(data.data1, newResponse.getResult().data1);
  Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx");
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:22,代码来源:SessionIdMessageTest.java


示例10: getEndpointForUser

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
private WebRtcEndpoint getEndpointForUser(final UserSession sender) {
  if (sender.getName().equals(name)) {
    log.debug("PARTICIPANT {}: configuring loopback", this.name);
    return outgoingMedia;
  }

  log.debug("PARTICIPANT {}: receiving video from {}", this.name, sender.getName());

  WebRtcEndpoint incoming = incomingMedia.get(sender.getName());
  if (incoming == null) {
    log.debug("PARTICIPANT {}: creating new endpoint for {}", this.name, sender.getName());
    incoming = new WebRtcEndpoint.Builder(pipeline).build();

    incoming.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {

      @Override
      public void onEvent(IceCandidateFoundEvent event) {
        JsonObject response = new JsonObject();
        response.addProperty("id", "iceCandidate");
        response.addProperty("name", sender.getName());
        response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
        try {
          synchronized (session) {
            session.sendMessage(new TextMessage(response.toString()));
          }
        } catch (IOException e) {
          log.debug(e.getMessage());
        }
      }
    });

    incomingMedia.put(sender.getName(), incoming);
  }

  log.debug("PARTICIPANT {}: obtained endpoint for {}", this.name, sender.getName());
  sender.getOutgoingWebRtcPeer().connect(incoming);

  return incoming;
}
 
开发者ID:jake-kent,项目名称:TLIVideoConferencingv2,代码行数:40,代码来源:UserSession.java


示例11: UserSession

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public UserSession(final String name, String roomName, final WebSocketSession session,
    MediaPipeline pipeline) {

  this.pipeline = pipeline;
  this.name = name;
  this.session = session;
  this.roomName = roomName;
  this.outgoingMedia = new WebRtcEndpoint.Builder(pipeline).build();

  this.outgoingMedia.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {

    @Override
    public void onEvent(IceCandidateFoundEvent event) {
      JsonObject response = new JsonObject();
      response.addProperty("id", "iceCandidate");
      response.addProperty("name", name);
      response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
      try {
        synchronized (session) {
          session.sendMessage(new TextMessage(response.toString()));
        }
      } catch (IOException e) {
        log.debug(e.getMessage());
      }
    }
  });
}
 
开发者ID:usmanullah,项目名称:kurento-testing,代码行数:28,代码来源:UserSession.java


示例12: startSession

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public String startSession(final WebSocketSession session, String sdpOffer) {
  // One KurentoClient instance per session (reserving points per session)
  Properties properties = new Properties();
  properties.add("loadPoints", POINTS_PER_SESSION);
  kurentoClient = KurentoClient.create(properties);
  log.info("Created kurentoClient (session {})", sessionId);

  // Media logic (pipeline and media elements connectivity)
  mediaPipeline = kurentoClient.createMediaPipeline();
  log.info("Created Media Pipeline {} (session {})", mediaPipeline.getId(), sessionId);

  webRtcEndpoint = new WebRtcEndpoint.Builder(mediaPipeline).build();
  FaceOverlayFilter faceOverlayFilter = new FaceOverlayFilter.Builder(mediaPipeline).build();
  faceOverlayFilter.setOverlayedImage("http://files.kurento.org/img/mario-wings.png", -0.35F,
      -1.2F, 1.6F, 1.6F);
  webRtcEndpoint.connect(faceOverlayFilter);
  faceOverlayFilter.connect(webRtcEndpoint);

  // WebRTC negotiation
  webRtcEndpoint.addOnIceCandidateListener(new EventListener<OnIceCandidateEvent>() {
    @Override
    public void onEvent(OnIceCandidateEvent event) {
      JsonObject response = new JsonObject();
      response.addProperty("id", "iceCandidate");
      response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
      handler.sendMessage(session, new TextMessage(response.toString()));
    }
  });
  String sdpAnswer = webRtcEndpoint.processOffer(sdpOffer);
  webRtcEndpoint.gatherCandidates();

  return sdpAnswer;
}
 
开发者ID:nubomedia,项目名称:nubomedia-magic-mirror,代码行数:34,代码来源:UserSession.java


示例13: kmsManager

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Bean
public KmsManager kmsManager() {
	JsonArray kmsUris =
			getPropertyJson(KurentoRoomServerApp.KMSS_URIS_PROPERTY,
					KurentoRoomServerApp.KMSS_URIS_DEFAULT, JsonArray.class);
	List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);

	log.info("Configuring Kurento Room Server to use the following kmss: "
			+ kmsWsUris);

	FixedNKmsManager fixedKmsManager =
			new FixedNKmsManager(kmsWsUris, DEMO_KMS_NODE_LIMIT);
	fixedKmsManager.setAuthRegex(DEMO_AUTH_REGEX);
	return fixedKmsManager;
}
 
开发者ID:sergiobanegas,项目名称:perseus,代码行数:16,代码来源:PerseusApp.java


示例14: kmsManager

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Override
public KmsManager kmsManager() {
  JsonArray kmsUris = getPropertyJson(KurentoRoomServerApp.KMSS_URIS_PROPERTY,
      KurentoRoomServerApp.KMSS_URIS_DEFAULT, JsonArray.class);
  List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);

  log.info("Configuring Kurento Room Server to use the following kmss: {}", kmsWsUris);

  FixedNKmsManager fixedKmsManager = new FixedNKmsManager(kmsWsUris, DEMO_KMS_NODE_LIMIT);
  fixedKmsManager.setAuthRegex(DEMO_AUTH_REGEX);
  log.debug("Authorization regex for new rooms: {}", DEMO_AUTH_REGEX);
  return fixedKmsManager;
}
 
开发者ID:Kurento,项目名称:kurento-room,代码行数:14,代码来源:KurentoRoomDemoApp.java


示例15: createUnsubscribeRequest

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
public RequestAndResponseType createUnsubscribeRequest(String objectRef,
    String listenerSubscription) {

  JsonObject params = JsonUtils.toJsonObject(
      new Props(UNSUBSCRIBE_OBJECT, objectRef).add(UNSUBSCRIBE_LISTENER, listenerSubscription));

  return new RequestAndResponseType(new Request<>(UNSUBSCRIBE_METHOD, params), Void.class);
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:9,代码来源:RomClientJsonRpcClient.java


示例16: transaction

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Override
@SuppressWarnings("serial")
public void transaction(final List<Operation> operations, final Continuation<Void> continuation) {

  JsonArray opJsons = new JsonArray();
  final List<RequestAndResponseType> opReqres = new ArrayList<>();

  int numReq = 0;
  for (Operation op : operations) {
    RequestAndResponseType reqres = op.createRequest(this);
    opReqres.add(reqres);
    reqres.request.setId(numReq);
    opJsons.add(JsonUtils.toJsonElement(reqres.request));
    numReq++;
  }

  JsonObject params = new JsonObject();
  params.add(TRANSACTION_OPERATIONS, opJsons);

  DefaultContinuation<List<Response<JsonElement>>> wrappedContinuation = null;

  if (continuation != null) {
    wrappedContinuation = new DefaultContinuation<List<Response<JsonElement>>>(continuation) {
      @Override
      public void onSuccess(List<Response<JsonElement>> responses) throws Exception {
        processTransactionResponse(operations, opReqres, responses);
        continuation.onSuccess(null);
      }
    };
  }

  List<Response<JsonElement>> responses = this.sendRequest(
      new Request<>(TRANSACTION_METHOD, params), new TypeToken<List<Response<JsonElement>>>() {
      }.getType(), null, wrappedContinuation);

  if (continuation == null) {
    processTransactionResponse(operations, opReqres, responses);
  }
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:40,代码来源:RomClientJsonRpcClient.java


示例17: handleInvokeCommand

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
private void handleInvokeCommand(Transaction transaction, String objectRef, String operationName,
    JsonObject operationParams) throws IOException {

  Object result = server.invoke(objectRef, operationName,
      JsonUtils.fromJson(operationParams, Props.class), Object.class);

  transaction.sendResponse(result);
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:9,代码来源:RomServerJsonRpcHandler.java


示例18: stringListConversion

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void stringListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive("XXX"));
  array.add(new JsonPrimitive("YYY"));
  array.add(new JsonPrimitive("ZZZ"));

  @SuppressWarnings("unchecked")
  List<String> list = JsonUtils.fromJson(array, List.class);

  assertEquals(list.get(0), "XXX");
  assertEquals(list.get(1), "YYY");
  assertEquals(list.get(2), "ZZZ");
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:16,代码来源:RomJsonConverterTest.java


示例19: integerListConversion

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void integerListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive(1));
  array.add(new JsonPrimitive(2));
  array.add(new JsonPrimitive(3));

  List<Integer> list = JsonUtils.fromJson(array, new TypeToken<List<Integer>>() {
  }.getType());

  assertEquals(list.get(0), (Integer) 1);
  assertEquals(list.get(1), (Integer) 2);
  assertEquals(list.get(2), (Integer) 3);
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:16,代码来源:RomJsonConverterTest.java


示例20: floatListConversion

import org.kurento.jsonrpc.JsonUtils; //导入依赖的package包/类
@Test
public void floatListConversion() {

  JsonArray array = new JsonArray();
  array.add(new JsonPrimitive(0.1));
  array.add(new JsonPrimitive(0.2));
  array.add(new JsonPrimitive(0.3));

  List<Float> list = JsonUtils.fromJson(array, new TypeToken<List<Float>>() {
  }.getType());

  assertEquals(list.get(0), 0.1, 0.01);
  assertEquals(list.get(1), 0.2, 0.01);
  assertEquals(list.get(2), 0.3, 0.01);
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:16,代码来源:RomJsonConverterTest.java



注:本文中的org.kurento.jsonrpc.JsonUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DOMUtilities类代码示例发布时间:2022-05-23
下一篇:
Java XMLUtils类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap