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


Java OnWebSocketMessage类代码示例

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


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

示例1: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String msg) {
    messages.add("[RECIVED at "+ System.currentTimeMillis() + "] " + msg);
    if (!closeConnectionPattern.isEmpty()){
    	if (closeConnectionExpression.matcher(msg).find()) {
            closeLatch.countDown();
            close();
        }
    }   
    if (this.waitMessage){
    	if (!waitResponsePatter.isEmpty()){
        	if (waitResponseExpresion.matcher(msg).find()) {
                messageLatch.countDown();
                this.waitMessage = false;
            }
        }   
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:19,代码来源:WebSocketConnection.java

示例2: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String msg) {
    JsonObject messageObject = new JsonParser().parse(msg).getAsJsonObject();
    long typeId = messageObject.get("TypeID").getAsLong();

    if(typeId == TYPE_ID_MESSAGE_RECEIVE) {
        JsonObject bodyObject = messageObject.getAsJsonObject("Body");
        System.out.println(bodyObject.get("Body").getAsString());
        if(!bodyObject.get("ClientID").getAsString().equals(messenger.getClientId())) {
            for(TwitchMessengerListener listener : messenger.getListeners()) {
                listener.onMessage(messenger
                        .getServer(bodyObject.get("ServerID").getAsString())
                        .getConversation(bodyObject.get("ConversationID").getAsString()), bodyObject.get("Body").getAsString());
            }
        }
    } else if(typeId == TYPE_ID_SIGNAL_PING) {
        // got pong
    } else if(typeId == TYPE_ID_SERVER_INFO) {
        // got server infos
    } else if(typeId == TYPE_ID_FRIENDS_STATUS_CHANGE) {
        // got friends status change events
    } else {
        System.out.println(String.format("Unhandled Web Socket Packet: %s, Message: %s", typeId, msg));
    }
}
 
开发者ID:renepreuss,项目名称:TwitchMessenger,代码行数:26,代码来源:TwitchNotificationSocket.java

示例3: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String msg) {
	synchronized (parent) {
		log.debug("Received message {" + sessionId + "}: " + msg);
		String length = " (" + msg.length() + " bytes)";
		logMessage.append(" - Received message #").append(messageCounter).append(length);
		logMessage.append(msg);
		addResponseMessage("[Message " + (messageCounter++) + "]\n" + msg + "\n\n");

		if (connectedExpression == null || connectedExpression.matcher(msg).find()) {
			logMessage.append("; matched connected pattern").append("\n");
			connectedLatch.countDown();
		} else if (subscribeExpression == null || subscribeExpression.matcher(msg).find()) {
			logMessage.append("; matched subscribe pattern").append("\n");
			subscribeLatch.countDown();
		} else if (!disconnectPattern.isEmpty() && disconnectExpression.matcher(msg).find()) {
			logMessage.append("; matched connection close pattern").append("\n");
			closeLatch.countDown();
			close(StatusCode.NORMAL, "JMeter closed session.");
		} else {
			logMessage.append("; didn't match any pattern").append("\n");
		}
	}
}
 
开发者ID:Fyro-Ing,项目名称:JMeter-WebSocket-StompSampler,代码行数:25,代码来源:ServiceSocket.java

示例4: turn

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void turn(final String message) throws IOException {
    LOGGER.info("Message :: Action received {}.", message);
    final Map<String, String> msg = this.mapper.readValue(message, MESSAGE_TYPE);
    final String action = msg.get("action");
    final WebGame game = this.player.getGame();
    switch (action) {
        case "pick":
            final String pit = msg.get("pit");
            final boolean over = game.pick(Integer.parseInt(pit));
            if (over) {
                this.games.remove(game.getId());
            }
            break;
        default:
            LOGGER.info("Unknown action {} received.", action);
    }
}
 
开发者ID:zshamrock,项目名称:stonesgame.io,代码行数:19,代码来源:GameSocket.java

示例5: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String msg) throws ParseException {
    //System.out.println("Received msg: " + msg);
    
	if(msg != null) {
		
		receivingData = true;
		lastMsg = msg;
		lastFrame = parser.parse(msg, controller);
		
		if (lastFrame != null) {
			//System.out.println(msg);
			receivingLeapData = true;
		}
	} else {
		receivingData = false;
		receivingLeapData = false;
	}
    
}
 
开发者ID:paluka,项目名称:Multi-Leap,代码行数:21,代码来源:ClientSocket.java

示例6: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String theMsg) {
	ourLog.info("Got msg: {}", theMsg);
	if (theMsg.startsWith("bound ")) {
		myGotBound = true;
		mySubsId = (theMsg.substring("bound ".length()));
		myPingCount++;
	} else if (myGotBound && theMsg.startsWith("add " + mySubsId + "\n")) {
		String text = theMsg.substring(("add " + mySubsId + "\n").length());
		IBaseResource res = myEncoding.newParser(myFhirCtx).parseResource(text);
		myReceived.add(res);
		myPingCount++;
	} else {
		myError = "Unexpected message: " + theMsg;
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:SubscriptionsDstu3Test.java

示例7: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String message) {
    logger.debug("Message received from server: {}", message);
    final JsonObject json = parser.parse(message).getAsJsonObject();
    if (json.has("id")) {
        logger.debug("Response received from server: {}", json);
        int messageId = json.get("id").getAsInt();
        if (messageId == nextMessageId - 1) {
            commandResponse = json;
            commandLatch.countDown();
        }
    } else {
        logger.debug("Event received from server: {}", json);
        if (eventHandler != null) {
            scheduler.submit(() -> {
                try {
                    eventHandler.handleEvent(json);
                } catch (Exception e) {
                    logger.debug("Error handling event {} player state change message: {}", json,
                            e.getMessage(), e);
                }
            });
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:26,代码来源:KodiClientSocket.java

示例8: onTextMethod

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onTextMethod(String stanza)
{
    XMPPPacketReader reader = null;
    try {
        reader = readerPool.borrowObject();
        Document doc = reader.read(new StringReader(stanza));

        if (xmppSession == null) {
            initiateSession(doc.getRootElement());
        } else {
            processStanza(doc.getRootElement());
        }
    } catch (Exception ex) {
        Log.error("Failed to process XMPP stanza", ex);
    } finally {
        if (reader != null) {
            readerPool.returnObject(reader);
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:XmppWebSocket.java

示例9: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String msg) {
    synchronized (parent) {
        log.debug("Received message: " + msg);
        String length = " (" + msg.length() + " bytes)";
        logMessage.append(" - Received message #").append(messageCounter).append(length);
        addResponseMessage("[Message " + (messageCounter++) + "]\n" + msg + "\n\n");

        if (responseExpression == null || responseExpression.matcher(msg).find()) {
            logMessage.append("; matched response pattern").append("\n");
            closeLatch.countDown();
        } else if (!disconnectPattern.isEmpty() && disconnectExpression.matcher(msg).find()) {
            logMessage.append("; matched connection close pattern").append("\n");
            closeLatch.countDown();
            close(StatusCode.NORMAL, "JMeter closed session.");
        } else {
            logMessage.append("; didn't match any pattern").append("\n");
        }
    }
}
 
开发者ID:maciejzaleski,项目名称:JMeter-WebSocketSampler,代码行数:21,代码来源:ServiceSocket.java

示例10: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
/**
 * Executed by web socket implementation when receiving a message from the
 * streams api. The message will be directly forwarded to the current 
 * {@link ActorSystem actor systems} {@link EventStream event stream} 
 * @param message
 */
@OnWebSocketMessage
public void onMessage(String message) {
	
	if(dispatcherIds.size() > dispatchers.size()) {
		// TODO
		ComponentLookupMessage componentLookup = new ComponentLookupMessage(ComponentType.DISPATCHER);
		for(String did : dispatcherIds) {
			if(!dispatchers.containsKey(did)) {
				componentLookup.addComponentId(did);
			}
		}
		if(!componentLookup.getComponentIds().isEmpty()) {
			this.componentRegistryRef.tell(componentLookup, getSelf());
			context().system().log().info("Component lookup issued by webtrends stream listener as still dispatcher references are missing [dispIds="+dispatcherIds.size()+", dispRefs="+dispatchers.size()+"]");
		}
	}
	
	try {
		for(final ActorRef ref : this.dispatchers.values()) {
			ref.tell(new StreamEventMessage(uuidGenerator.generate().toString(), EVENT_SOURCE_ID, sdf.format(new Date()), message), getSender());
		}
	} catch(Exception e) {
		logger.error("Failed to insert webtrends stream event into processing pipeline. Error: " + e.getMessage());
	}
}
 
开发者ID:mnxfst,项目名称:stream-analyzer,代码行数:32,代码来源:WebtrendsStreamListenerActor.java

示例11: handleMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
  public void handleMessage(String message) {
String uri = session.getUpgradeRequest().getRequestURI().getPath();
LOG.debug("websocket message: " + uri);

//find hanlder
WebSocketHandler handler = getHandler(uri);
if (handler == null) {
	session.getUpgradeResponse().setStatusCode(404);
	return;
}

//get file
String file = handler.getMessage();
if (StringUtils.isEmpty(file)) {
	return;
}

bindAndRun(handler, file, message, null);
  }
 
开发者ID:lane-cn,项目名称:getty,代码行数:21,代码来源:WebSocketInstance.java

示例12: onText

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onText(Session session, String message) {
    try {
        // handle 'unlock' request
        if(message.equals("unlock")){
            session.getRemote().sendString(AccessControl.unlock() ? "unlock=success" : "unlock=fail");
        }

        // handle 'violation' request
        else if(message.equals("violation")){
            session.getRemote().sendString("violation=" + AccessControl.getSecurityViolation().getName());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:savagehomeautomation,项目名称:pi4j-javaone-demos,代码行数:18,代码来源:AccessControlWebSocket.java

示例13: onText

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
  public void onText(String msg) throws ClassNotFoundException, IllegalAccessException, InstantiationException, IOException, JFException {
  	System.out.println("rec "+msg );
	//session.getRemote().sendString(gson.toJson(new Message("msg", "received and processed by "+strategy)));

  	String[] d  = msg.split("/");
switch(d[0]){
		
	case "ticks": 			send(session, Ticks()); break;
	case "subscribe": 		Subscribe(d[1]); break;
	
	case "close": 			client.startStrategy(new CloseStrategy(session, d[2])); break;
	case "partialclose": 	client.startStrategy(new PartialCloseStrategy(session, d[2], d[3])); break;
	case "sl": 				client.startStrategy(new SetSLStrategy(session, d[2], d[3])); break;
	case "tp": 				client.startStrategy(new SetTPStrategy(session, d[2], d[3])); break;
	case "open":			client.startStrategy(new OpenStrategy(session, d[2], d[3], d[4])); break;
	case "news": 			client.startStrategy(new NewsStrategy(session)); break;
	
	case "help":  default: send(session, new String[]{"ticks", "subscribe", "close", "open", "sl", "tp", "..."}); break;
	
}
  }
 
开发者ID:caub,项目名称:JForexJetty,代码行数:23,代码来源:DataStrategy.java

示例14: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String data) {
    for (ChatWebSocket user : users) {
        try {
            user.getSession().getRemote().sendString(data);
            System.out.println("Sending message: " + data);
        } catch (Exception e) {
            System.out.print(e.toString());
        }
    }
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:12,代码来源:ChatWebSocket.java

示例15: onMessage

import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String message)
{
	String[] split = message.split(",");
	if (split.length == 5)
	{
		try
		{
			this.nextFaceDataIndex = (this.nextFaceDataIndex + 1) % this.faceData.length;
			long timestamp = Long.parseLong(split[0]);
			int camID = Integer.parseInt(split[1]);
			boolean face = !split[2].equals("0");
			boolean leftEye = !split[3].equals("0");
			boolean rightEye = !split[4].equals("0");
			this.faceData[this.nextFaceDataIndex].timestamp = timestamp;
			this.faceData[this.nextFaceDataIndex].camID = camID;
			this.faceData[this.nextFaceDataIndex].face = face;
			this.faceData[this.nextFaceDataIndex].leftEye = leftEye;
			this.faceData[this.nextFaceDataIndex].rightEye = rightEye;
			this.runFaceAverager(this.nextFaceDataIndex);
		}
		catch (Throwable e)
		{
			log.info(MainDialog.now + " recieved bad UWAPI message: {}", message);
			e.printStackTrace();
		}
	}
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:29,代码来源:UltiwakerWebSocketHandler.java


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