當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。