本文整理汇总了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;
}
}
}
}
示例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));
}
}
示例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");
}
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
});
}
}
}
示例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);
}
}
}
示例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");
}
}
}
示例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());
}
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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());
}
}
}
示例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();
}
}
}