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


Java CreditsException类代码示例

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


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

示例1: throwDart

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
public void throwDart(double x, double y, double z) throws CreditsException {
    if (this.isFlying()) {
        throw new CreditsException(-10, "Can't throw if flying");
    }
    
    if (z >= 0) {
        //fail throw
        return;
    }
    
    this.timestamp = new Date().getTime();
    
    this.setImpulse(IBody.Axis.X, x);
    this.setImpulse(IBody.Axis.Y, y);
    this.setImpulse(IBody.Axis.Z, z);
    
    this.updateOwner(true, true, false);
    
    this.startX = this.x;
    this.startY = this.y;
    this.startZ = this.z;

}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:24,代码来源:Dart.java

示例2: forcePosition

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
public void forcePosition(double x, double y, double z) throws CreditsException {
    if (this.isFlying()) {
        //throw new CreditsException(-12, "Can't move around while flying");
        return;
    }
    
    if (z < Constants.ARM_REACH) {
        //you need to throw the dart!
        throw new CreditsException(-13, "Are you trying to cheat? Throw your dart!");
    }
    
    this.x = x;
    this.y = y;
    this.z = z;
    
    this.updateOwner(true, false, false);
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:18,代码来源:Dart.java

示例3: loadFeed

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
private void loadFeed() throws CreditsException {
    if (this.feed == null) {
         try {
             // Get the LeapMotionDataAdapter instance to bind it with this
             // Metadata Adapter and send chat messages through it
             this.feed = DartDataAdapter.feedMap.get(this.adapterSetId);
         } catch(Throwable t) {
             // It can happen if the Chat Data Adapter jar was not even
             // included in the Adapter Set lib directory (the LeapMotion
             // Data Adapter could not be included in the Adapter Set as well)
             logger.error("LeapMotionDataAdapter class was not loaded: " + t);
             throw new CreditsException(0, "No feed available", "No feed available");
         }

         if (this.feed == null) {
             // The feed is not yet available on the static map, maybe the
             // LeapMotion Data Adapter was not included in the Adapter Set
             logger.error("LeapMotionDataAdapter not found");
             throw new CreditsException(0, "No feed available", "No feed available");
         }
    }
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:23,代码来源:DartMetaDataAdapter.java

示例4: notifySessionClose

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
@Override
public void notifySessionClose(String session) throws NotificationException {
    synchronized(sessions) {
        //we have to remove session informations from the session HashMap
        logger.info("Clearing session " + session);
        Map<String,String> sessionInfo = sessions.remove(session);
        String id = sessionInfo.get(Constants.USER_ID);
        if (id != null) {
            ids.remove(id);
            
            try {
                this.loadFeed();
            } catch (CreditsException e) {
                logger.error("Unexpected: feed not available");
                return;
            }
            
            ChatRoom chat = this.feed.getChatFeed();
            chat.leaveAllRooms(id);
            chat.stopUser(id);
        }
    }
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:24,代码来源:DartMetaDataAdapter.java

示例5: notifyNewSession

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" }) 
public void notifyNewSession(String user, String session, Map clientContext)
    throws CreditsException, NotificationException {

    // We can't have duplicate sessions
    assert(!sessions.containsKey(session));

    /* If needed, modify the user agent and store it directly
     * in the session infos object, for logging support.
     * Note: we are free to change and store the received object.
     */
    uniquelyIdentifyClient(clientContext);

    // Register the session details on the sessions HashMap,
    // for Chat and Monitor support.
    sessions.put(session, clientContext);
}
 
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-MPNStockListMetadata-adapter-java,代码行数:19,代码来源:StockQuotesMetadataAdapter.java

示例6: notifyUserMessage

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
/**
 * Triggered by a client "sendMessage" call.
 * The message encodes an instant message from the client.
 */
public void notifyUserMessage(String user, String session, String message)
    throws NotificationException, CreditsException {

    if (message == null) {
        logger.warn("Null message received");
        throw new NotificationException("Null message received");
    }

    //Split the string on the | character
    //The message must be of the form "IM|fromId|toId|message"
    String[] pieces = message.split("\\|", -1);

    this.loadIMFeed();
    this.handleIMMessage(pieces, message, user);
}
 
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-Messenger-adapter-java,代码行数:20,代码来源:IMMetadataAdapter.java

示例7: loadIMFeed

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
private void loadIMFeed() throws CreditsException {
    if (this.IMFeed == null) {
        try {
            // Get the IMDataAdapter instance to bind it with this
            // Metadata Adapter and send instant messages through it
            this.IMFeed = IMDataAdapter.feedMap.get(this.adapterSetId);
        } catch (Throwable t) {
            // It can happen if the Messenger Data Adapter jar was not even
            // included in the Adapter Set lib directory (the Messenger
            // Data Adapter could not be included in the Adapter Set as
            // well)
            logger.error("IMDataAdapter class was not loaded: " + t);
            throw new CreditsException(0, "No IM feed available",
                    "No IM feed available");
        }

        if (this.IMFeed == null) {
            // The feed is not yet available on the static map, maybe the
            // Messenger Data Adapter was not included in the Adapter Set
            logger.error("IMDataAdapter not found");
            throw new CreditsException(0, "No IM feed available",
                    "No IM feed available");
        }
    }
}
 
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-Messenger-adapter-java,代码行数:26,代码来源:IMMetadataAdapter.java

示例8: notifyUserMessage

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
/**
 * Triggered by a client "sendMessage" call.
 * The message encodes a chat message from the client.
 */
public void notifyUserMessage(String user, String session, String message)
    throws NotificationException, CreditsException {

    if (message == null) {
        logger.warn("Null message received");
        throw new NotificationException("Null message received");
    }

    //Split the string on the | character
    //The message must be of the form "RT|n|message" 
    //(where n is the number that identifies the item
    //and message is the message to be published)
    String[] pieces = message.split("\\|", -1);

    this.loadRTFeed();
    this.handleRTMessage(pieces,message,session);
}
 
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-RoundTrip-adapter-java,代码行数:22,代码来源:RoundTripMetadataAdapter.java

示例9: loadRTFeed

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
private void loadRTFeed() throws CreditsException {
    if (this.rtFeed == null) {
         try {
             // Get the RoundTripDataAdapter instance to bind it with this
             // Metadata Adapter and send chat messages through it
             this.rtFeed = RoundTripDataAdapter.feedMap.get(this.adapterSetId);
         } catch(Throwable t) {
             // It can happen if the RoundTrip Data Adapter jar was not even
             // included in the Adapter Set lib directory (the RoundTrip
             // Data Adapter could not be included in the Adapter Set as well)
             logger.error("RoundTripDataAdapter class was not loaded: " + t);
             throw new CreditsException(0, "No roundtrip feed available", "No roundtrip feed available");
         }

         if (this.rtFeed == null) {
             // The feed is not yet available on the static map, maybe the
             // RoundTrip Data Adapter was not included in the Adapter Set
             logger.error("RoundTripDataAdapter not found");
             throw new CreditsException(0, "No roundtrip feed available", "No roundtrip feed available");
         }
    }
}
 
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-RoundTrip-adapter-java,代码行数:23,代码来源:RoundTripMetadataAdapter.java

示例10: release

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
public void release(String playerId, String worldId, double x, double y, double z) throws CreditsException {
    if (!worlds.containsKey(worldId)) {
        return;
    }
    if (logger.isTraceEnabled()) {
        logger.trace("Forwarding throw command for player" + playerId + " to world " + worldId);
    }
    World world = worlds.get(worldId);
    world.release(playerId,x,y,z);
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:11,代码来源:Universe.java

示例11: move

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
public void move(String playerId, String worldId, double x, double y, double z) throws CreditsException {
    if (!worlds.containsKey(worldId)) {
        return;
    }
    if (logger.isTraceEnabled()) {
        logger.trace("Forwarding move command for player" + playerId + " to world " + worldId);
    }
    World world = worlds.get(worldId);
    world.move(playerId,x,y,z);
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:11,代码来源:Universe.java

示例12: release

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
public synchronized void release(String playerId, double x, double y, double z) throws CreditsException {
    if (!this.darts.containsKey(playerId)) {
        return;
    }
    if (logger.isTraceEnabled()) {
        logger.trace(this.id+"|throwing " + id);
    }
    Dart player = this.darts.get(playerId);
    player.throwDart(x,y,z);
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:11,代码来源:World.java

示例13: move

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
public synchronized void move(String playerId, double x, double y, double z) throws CreditsException {
    if (!this.darts.containsKey(playerId)) {
        return;
    }
    if (logger.isTraceEnabled()) {
        logger.trace(this.id+"|moving " + id);
    }
    Dart player = this.darts.get(playerId);
    player.forcePosition(x, y, z);
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:11,代码来源:World.java

示例14: getDoubles

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
private static double[] getDoubles(String[] values) throws CreditsException {
    if (values.length != 4) {
        throw new CreditsException(-4, "wrongly formatted message");
    }
    double[] res = new double[3];
    try {
        res[0] = Double.parseDouble(values[1]);
        res[1] = Double.parseDouble(values[2]);
        res[2] = Double.parseDouble(values[3]);
    } catch(NumberFormatException nf) {
        throw new CreditsException(-5, "wrongly formatted number");
    }
    return res;
}
 
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:15,代码来源:DartMetaDataAdapter.java

示例15: handleIMMessage

import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
private void handleIMMessage(String[] pieces, String fullMessage, String user)
        throws CreditsException {

    // Check the message, it must be of the form "IM|fromId|toId|message"
    if (pieces[0].equals("IM")) {
        if (pieces.length < 4) {
            logger.warn("Wrong message received: " + fullMessage);
            throw new CreditsException(1, "Wrong message received", "Wrong message");
        }
        String from = pieces[1];
        String to = pieces[2];

        // here we should check that the <user> is enabled to send
        // messages on behalf of the <from> nickname

        String message = pieces[3];
        if (pieces.length > 4) {
            // Ooops! There are '|' characters in the message
            // (the client should prevent '|' characters in the nicknames)
            for (int i = 4; i < pieces.length; i++) {
                message += "|";
                message += pieces[i];
            }
        }
        this.IMFeed.sendMessage(from, to, message);
    }
}
 
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-Messenger-adapter-java,代码行数:28,代码来源:IMMetadataAdapter.java


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