本文整理汇总了Java中com.lightstreamer.interfaces.metadata.CreditsException类的典型用法代码示例。如果您正苦于以下问题:Java CreditsException类的具体用法?Java CreditsException怎么用?Java CreditsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreditsException类属于com.lightstreamer.interfaces.metadata包,在下文中一共展示了CreditsException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: notifyUserMessage
import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
@Override
public void notifyUserMessage(String user, String sessionID, String message) throws CreditsException, NotificationException {
if (message.startsWith("n|")) {
notifyUserName(sessionID, message.substring(2));
} else {
String userName= "";
synchronized (this) {
userName= _userNamesBySessionId.get(sessionID);
// Check if user is connected
if (userName == null)
return; // We assume it is a late message, that can be ignored
}
// Extract user's data
String [] segments= message.split("\\|");
if (segments.length < 10)
throw new NotificationException("Maformed message received");
String involvedKey= (segments[0].trim().length() > 0) ? segments[0] : null;
String upOrDown= (segments[1].trim().length() > 0) ? segments[1] : null;
String xLoc= (segments[2].trim().length() > 0) ? segments[2] : null;
String yLoc= (segments[3].trim().length() > 0) ? segments[3] : null;
String power= (segments[4].trim().length() > 0) ? segments[4] : null;
String xWindowOffset= (segments[5].trim().length() > 0) ? segments[5] : null;
String yWindowOffset= (segments[6].trim().length() > 0) ? segments[6] : null;
String map1= (segments[7].trim().length() > 0) ? segments[7] : null;
String map2= (segments[8].trim().length() > 0) ? segments[8] : null;
String area= (segments[9].trim().length() > 0) ? segments[9] : null;
if ((xLoc == null) || (yLoc == null) || (power == null) || (xWindowOffset == null) || (yWindowOffset == null) || (map1 == null) || (map2 == null) || (area == null))
throw new NotificationException("Malformed message recevied");
// Notify data adapter
DataAdapter.getInstance().onUserUpdated(userName, involvedKey, upOrDown, xLoc, yLoc, power, xWindowOffset, yWindowOffset, map1, map2, area);
}
}
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-FullScreenMario-adapter-java,代码行数:40,代码来源:MetadataAdapter.java
示例17: notifyUserName
import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
private void notifyUserName(String sessionID, String userName) throws CreditsException {
synchronized (this) {
if ((userName == null) || (userName.trim().length() == 0)) {
throw new CreditsException(-100, "Nickname must be specified");
} else if (userName.startsWith(DataAdapter.ITEM_NAME_USER_LIST_PREFIX)) {
throw new CreditsException(-109, "Nice try, man");
} else if (_userNamesBySessionId.containsKey(sessionID)) {
if (_userNamesBySessionId.get(sessionID).equals(userName))
return; // Received the same nickname more than once, just ignore it
// Different nickname on the same session it's evil
throw new CreditsException(-2710, "User already logged on same session.");
} else if (_sessionIdsByUserName.containsKey(userName)) {
// Append a number (beginning with 2) to the user name
int ik= 2;
while (_sessionIdsByUserName.containsKey(userName + ik))
ik++;
userName= userName + ik;
this.initUser(sessionID, userName);
// Client will parse this exception and update its user name
throw new CreditsException(-2720, userName);
} else if (_sessionIdsByUserName.size() > 200)
throw new CreditsException(-2700, "Too many users. Please try again later.");
this.initUser(sessionID, userName);
}
}
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-FullScreenMario-adapter-java,代码行数:35,代码来源:MetadataAdapter.java
示例18: notifyNewTables
import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
@Override
public void notifyNewTables(java.lang.String user, java.lang.String sessionID, TableInfo[] tables) throws CreditsException {
if (tables[0].getId().startsWith(LOGON_CUSTOM_PREFIX)) {
String item = tables[0].getId().substring(LOGON_CUSTOM_PREFIX.length());
String pieces[] = item.split("_");
if ( Move3dAdapter.tooManyUsers() ) {
throw new CreditsException(-3, "Too many users, please wait ... ");
}
if ( Move3dAdapter.worldOvercrwoded(tables[0].getId()) ) {
throw new CreditsException(-3, "This world is full and you are a watcher. Teleport yourself to another world to become an active player");
}
if (pieces.length > 1) {
players.put(sessionID, pieces[1]);
}
} else if ( tables[0].getId().startsWith(BAND_PREFIX) ) {
String usr = tables[0].getId().substring(BAND_PREFIX.length());
PollsBandwidth p = new PollsBandwidth(sessionID, usr, this.jmxPort);
ScheduledFuture<?> tsk = executor.scheduleAtFixedRate(p,10,2000,TimeUnit.MILLISECONDS);
p.setTask(tsk);
checkBandWidths.put(tables[0].getId(), p);
} else if ( tables[0].getId().startsWith("ServerSide") ) {
if (curSrvSideUsers < maxSrvSideUsers) {
curSrvSideUsers++;
logger.debug("Current Server side players: " + curSrvSideUsers);
} else {
logger.warn("Too many server side players, upgrade rejected.");
throw new CreditsException(-3, "Too many server side players!");
}
}
}
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-3DWorld-adapter-java,代码行数:35,代码来源:Move3dMetaAdapter.java
示例19: getItems
import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
@Override
public String[] getItems(String user, String session, String group)
throws ItemsException {
String[] split = super.getItems(user,session,group);
for (int i = 0; i<split.length; i++) {
String val;
if (( val = Constants.getVal(split[i],Constants.USER_SUBSCRIPTION)) != null) {
synchronized(sessions) {
Map<String,String> sessionInfo = sessions.get(session);
if (sessionInfo == null) {
logger.warn("Can't find session " + session);
throw new ItemsException("Can't find session");
}
if (sessionInfo.containsKey(Constants.USER_ID)) {
//currently permit only one id per session
String prevVal = sessionInfo.get(Constants.USER_ID);
if (!val.equals(prevVal)) {
logger.warn("Session alredy owns an ID: " + val);
throw new ItemsException("Session alredy owns an ID: " + val);
}
} else {
if (ids.containsKey(val)) {
logger.debug("Id already taken: " + val);
throw new ItemsException("Id already taken, try again");
}
sessionInfo.put(Constants.USER_ID, val);
}
ids.put(val, session);
try {
this.loadFeed();
} catch (CreditsException e) {
throw new ItemsException("Feed unavailable");
}
ChatRoom chat = this.feed.getChatFeed();
chat.startUser(val);
split[i] = Constants.USER_SUBSCRIPTION + val;
}
}
}
return split;
}
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:46,代码来源:DartMetaDataAdapter.java
示例20: notifyNewSession
import com.lightstreamer.interfaces.metadata.CreditsException; //导入依赖的package包/类
@Override
public void notifyNewSession(String user, String session, Map sessionInfo) throws CreditsException, NotificationException {
// Register the session details on the sessions HashMap.
logger.info("New session available " + session);
sessions.put(session, sessionInfo);
}
开发者ID:Lightstreamer,项目名称:BananaDarts-adapter-java,代码行数:7,代码来源:DartMetaDataAdapter.java
注:本文中的com.lightstreamer.interfaces.metadata.CreditsException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论