当前位置: 首页>>代码示例>>Java>>正文


Java InboundEvent.getName方法代码示例

本文整理汇总了Java中org.glassfish.jersey.media.sse.InboundEvent.getName方法的典型用法代码示例。如果您正苦于以下问题:Java InboundEvent.getName方法的具体用法?Java InboundEvent.getName怎么用?Java InboundEvent.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.glassfish.jersey.media.sse.InboundEvent的用法示例。


在下文中一共展示了InboundEvent.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEvent

import org.glassfish.jersey.media.sse.InboundEvent; //导入方法依赖的package包/类
@Override
public void onEvent(InboundEvent inboundEvent) {
	String eventName = inboundEvent.getName();
	if (mainEventName.equals(eventName)) {
		Optional<Response<T>> resp;
		try {
			resp = responseBuilder.buildResponse(inboundEvent.readData(), clazz, uri);
		} catch (Exception e) {
			sseObserver.onParseError(new ParseError(inboundEvent.getId(), e, inboundEvent.getRawData()));
			return;
		}
		sseObserver.onEvent(resp.get());
	} else {
		sseObserver.onSignal(eventName);
	}

}
 
开发者ID:Mercateo,项目名称:rest-hateoas-client,代码行数:18,代码来源:SSEListener.java

示例2: onEvent

import org.glassfish.jersey.media.sse.InboundEvent; //导入方法依赖的package包/类
private void onEvent(InboundEvent inboundEvent) {
    try {
        lastEventTimestamp = System.currentTimeMillis();

        String name = inboundEvent.getName();
        String data = inboundEvent.readData();

        logger.debug("Received '{}' event, data: {}", name, data);

        if (!connected) {
            logger.debug("Connected to streaming events");
            connected = true;
            listeners.forEach(listener -> listener.onConnected());
        }

        if (AUTH_REVOKED.equals(name)) {
            logger.debug("API authorization has been revoked for access token: {}", data);
            listeners.forEach(listener -> listener.onAuthorizationRevoked(data));
        } else if (ERROR.equals(name)) {
            logger.warn("Error occurred: {}", data);
            listeners.forEach(listener -> listener.onError(data));
        } else if (KEEP_ALIVE.equals(name)) {
            logger.debug("Received message to keep connection alive");
        } else if (OPEN.equals(name)) {
            logger.debug("Event stream opened");
        } else if (PUT.equals(name)) {
            logger.debug("Data has changed (or initial data sent)");
            lastReceivedTopLevelData = gson.fromJson(data, TopLevelStreamingData.class).getData();
            listeners.forEach(listener -> listener.onNewTopLevelData(lastReceivedTopLevelData));
        } else {
            logger.debug("Received unhandled event with name '{}' and data '{}'", name, data);
        }
    } catch (Exception e) {
        // catch exceptions here otherwise they will be swallowed by the implementation
        logger.warn("An exception occurred while processing the inbound event", e);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:38,代码来源:NestStreamingRestClient.java

示例3: eventSourceThree

import org.glassfish.jersey.media.sse.InboundEvent; //导入方法依赖的package包/类
void eventSourceThree()
    {


        eventSource = new EventSource(target) {
            @Override
            public void onEvent(InboundEvent inboundEvent) {

//                if ("message-to-client".equals(inboundEvent.getName())) {
                System.out.println(inboundEvent.getName() + "; "
                        + inboundEvent.readData(String.class));

                String eventName = inboundEvent.getName();
                String message = inboundEvent.readData(String.class);


                NotificationCompat.Builder mBuilder =
                        new NotificationCompat.Builder(IntentServiceSSE.this)
                                .setContentTitle(eventName)
                                .setContentText(message)
                                .setContentInfo(message)
                                .setSmallIcon(R.mipmap.shopping_basket_png)
                                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));


                NotificationManager mNotificationManager =
                        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

                mNotificationManager.notify(2, mBuilder.build());
            }


        };
    }
 
开发者ID:SumeetMoray,项目名称:Nearby-Shops-End-User-Android-app,代码行数:35,代码来源:IntentServiceSSE.java

示例4: handleNotificationThree

import org.glassfish.jersey.media.sse.InboundEvent; //导入方法依赖的package包/类
void handleNotificationThree()
    {
        Client client = ClientBuilder.newBuilder()
                .register(SseFeature.class).build();


        int endUserID = -1;

        if(UtilityLogin.getEndUser(getBaseContext())!=null)
        {
            endUserID = UtilityLogin.getEndUser(getBaseContext()).getEndUserID();
        }
        else
        {
            return;
        }


        System.out.println("On Handle Intent : Handle Notification !");

        String url = UtilityGeneral.getServiceURL(MyApplication.getAppContext()) + "/api/v1/EndUser/Notifications/" + String.valueOf(endUserID);

        System.out.println("URL : " + url);
//        logMessage("URL : " + url);


        WebTarget target = client.target(url);

        eventSourceThree = EventSource.target(target)
                .reconnectingEvery(5,TimeUnit.SECONDS)
                .build();



        EventListener listener = new EventListener() {
            @Override
            public void onEvent(InboundEvent inboundEvent) {


                    System.out.println(inboundEvent.getName() + "; "
                            + inboundEvent.readData(String.class));

                    String eventName = inboundEvent.getName();
                    String message = inboundEvent.readData(String.class);


                    NotificationCompat.Builder mBuilder =
                            new NotificationCompat.Builder(IntentServiceSSE.this)
                                    .setContentTitle(eventName)
                                    .setContentText(message)
                                    .setContentInfo(message)
                                    .setSmallIcon(R.mipmap.shopping_basket_png)
                                    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));


                    NotificationManager mNotificationManager =
                            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

                    mNotificationManager.notify(2, mBuilder.build());
            }
        };



        eventSourceThree.register(listener);
        eventSourceThree.open();


    }
 
开发者ID:SumeetMoray,项目名称:Nearby-Shops-End-User-Android-app,代码行数:70,代码来源:IntentServiceSSE.java


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