Codota Logo
AVIMClient
Code IndexAdd Codota to your IDE (free)

How to use
AVIMClient
in
cn.leancloud.im.v2

Best Java code snippets using cn.leancloud.im.v2.AVIMClient (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: cn.leancloud/realtime-core

private void refreshConversationThenNotify(final AVIMMessage message, final SimpleCallback callback) {
 if (null == message || null == callback) {
  return;
 }
 final AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId());
 final AVIMConversation conversation = client.getConversation(message.getConversationId(), convType);
 refreshConversationThenNotify(conversation, callback);
}
origin: cn.leancloud/realtime-core

/**
 * get AVIMClient instance by clientId.
 * @param clientId
 * @return
 */
public static AVIMClient getInstance(String clientId) {
 if (StringUtil.isEmpty(clientId)) {
  return null;
 }
 AVIMClient client = clients.get(clientId);
 if (null == client) {
  client = new AVIMClient(clientId);
  AVIMClient elderClient = clients.putIfAbsent(clientId, client);
  if (null != elderClient) {
   client = elderClient;
  }
 }
 return client;
}
origin: cn.leancloud/realtime-core

/**
 * Create a new temporary Conversation
 *
 * @param conversationMembers
 * @param ttl
 * @param callback
 */
public void createTemporaryConversation(final List<String> conversationMembers, int ttl, final AVIMConversationCreatedCallback callback) {
 this.createConversation(conversationMembers, null, null, false, true, true, ttl, callback);
}
origin: cn.leancloud/realtime-core

/**
 * get conversation by id and type
 *
 * @param conversationId
 * @param convType
 * @return
 */
public AVIMConversation getConversation(String conversationId, int convType) {
 AVIMConversation result = null;
 switch (convType) {
  case Conversation.CONV_TYPE_SYSTEM:
   result = getServiceConversation(conversationId);
   break;
  case Conversation.CONV_TYPE_TEMPORARY:
   result = getTemporaryConversation(conversationId);
   break;
  case Conversation.CONV_TYPE_TRANSIENT:
   result = getChatRoom(conversationId);
   break;
  default:
   result = getConversation(conversationId);
   break;
 }
 return result;
}
origin: cn.leancloud/realtime-core

public static AVIMClient getInstance(AVUser user, String tag) {
 AVIMClient client = getInstance(user);
 client.tag = tag;
 return client;
}
origin: cn.leancloud/realtime-core

/**
 * 增加查询条件,指定聊天室的组员条件满足条件的才返回
 *
 * @param peerIds
 * @param includeSelf  是否包含自己
 * @return
 */
public AVIMConversationsQuery withMembers(List<String> peerIds, boolean includeSelf) {
 Set<String> targetPeerIds = new HashSet<String>(peerIds);
 if (includeSelf) {
  targetPeerIds.add(client.getClientId());
 }
 containsMembers(new LinkedList<String>(targetPeerIds));
 this.whereSizeEqual(Conversation.MEMBERS, targetPeerIds.size());
 return this;
}
origin: cn.leancloud/realtime-core

void queryConversationMemberInfo(final QueryConditions queryConditions, final AVIMConversationMemberQueryCallback cb) {
 if (null == queryConditions || null == cb) {
  return;
 }
 if (!realtimeSessionTokenExpired()) {
  queryConvMemberThroughNetwork(queryConditions, cb);
 } else {
  // refresh realtime session token.
  LOGGER.d("realtime session token expired, start to refresh...");
  boolean ret = InternalConfiguration.getOperationTube().renewSessionToken(this.getClientId(), new AVIMClientCallback() {
   @Override
   public void done(AVIMClient client, AVIMException e) {
    if (null != e) {
     cb.internalDone(null, AVIMException.wrapperAVException(e));
    } else {
     queryConvMemberThroughNetwork(queryConditions, cb);
    }
   }
  });
  if (!ret) {
   cb.internalDone(null, new AVException(AVException.OPERATION_FORBIDDEN, "couldn't start service in background."));
  }
 }
}
origin: cn.leancloud/realtime-core

void updateRealtimeSessionToken(String sessionToken, int expireInSec) {
 this.realtimeSessionToken = sessionToken;
 this.realtimeSessionTokenExpired = System.currentTimeMillis() + expireInSec * 1000;
 AVIMClient.getInstance(this.getSelfPeerId()).updateRealtimeSessionToken(sessionToken, this.realtimeSessionTokenExpired/1000);
 if (StringUtil.isEmpty(sessionToken)) {
  AVSessionCacheHelper.IMSessionTokenCache.removeIMSessionToken(getSelfPeerId());
 } else {
  AVSessionCacheHelper.IMSessionTokenCache.addIMSessionToken(getSelfPeerId(), sessionToken,
      realtimeSessionTokenExpired);
 }
}
origin: cn.leancloud/realtime-core

/**
 * get default clientId.
 * @return
 */
public static String getDefaultClient() {
 if (getClientsCount() == 1) {
  return clients.keySet().iterator().next();
 }
 return "";
}
origin: cn.leancloud/realtime-core

protected static void processMessageReceipt(AVIMMessage message, AVIMClient client) {
 client.getStorage().updateMessage(message, message.getMessageId());
 message = parseTypedMessage(message);
 final AVIMConversation conversation = client.getConversation(message.getConversationId());
 retrieveAllMessageHandlers(message, conversation, true);
}
origin: cn.leancloud/realtime-core

/**
 * get an existed conversation
 *
 * @param conversationId
 * @param isTransient
 * @param isTemporary
 * @return
 */
public AVIMConversation getConversation(String conversationId, boolean isTransient, boolean isTemporary) {
 return this.getConversation(conversationId, isTransient, isTemporary,false);
}
origin: cn.leancloud/realtime-core

/**
 * Create a new temporary Conversation
 *
 * @param conversationMembers
 * @param callback
 */
public void createTemporaryConversation(final List<String> conversationMembers, final AVIMConversationCreatedCallback callback) {
 this.createTemporaryConversation(conversationMembers, 86400*3, callback);
}
origin: cn.leancloud/realtime-core

public static AVIMClientEventHandler getClientEventHandler() {
 return AVIMClient.getClientEventHandler();
}
origin: cn.leancloud/realtime-core

@Override
protected final void processEvent0(int operation, Object operator, Object operand,
                  Object eventScene) {
 switch (operation) {
  case Conversation.STATUS_ON_CONNECTION_RESUMED:
   onConnectionResume((AVIMClient) eventScene);
   break;
  case Conversation.STATUS_ON_CONNECTION_PAUSED:
   onConnectionPaused((AVIMClient) eventScene);
   break;
  case Conversation.STATUS_ON_CLIENT_OFFLINE:
   onClientOffline((AVIMClient) eventScene, (Integer) operand);
   ((AVIMClient) eventScene).close(null); // TODO: FIXME
   break;
  default:
   LOGGER.d("Not supported operation:" + operand);
 }
}
origin: cn.leancloud/realtime-core

/**
 * get AVIMClient instance by clientId and tag.
 * @param clientId
 * @param tag
 * @return
 */
public static AVIMClient getInstance(String clientId, String tag) {
 AVIMClient client = getInstance(clientId);
 client.tag = tag;
 return client;
}
origin: cn.leancloud/realtime-core

public static void processMessage(AVIMMessage message, int convType, AVIMClient client, boolean hasMore,
                 boolean isTransient) {
 message.setCurrentClient(client.getClientId());
 AVIMMessageManager.processMessage(message, convType, client, hasMore, isTransient);
}
origin: cn.leancloud/realtime-core

public static MessagePatchModifiedPacket getPatchMessagePacket(String peerId, long lastPatchTime) {
 MessagePatchModifiedPacket messagePatchModifiedPacket = new MessagePatchModifiedPacket();
 if (AVIMClient.getClientsCount() > 1) {
  // peerId is necessary only when more than 1 client logined.
  messagePatchModifiedPacket.setPeerId(peerId);
 }
 messagePatchModifiedPacket.lastPatchTime = lastPatchTime;
 return messagePatchModifiedPacket;
}
origin: cn.leancloud/realtime-core

protected static void processMessage(AVIMMessage message, int convType, AVIMClient client, boolean hasMore,
                   boolean isTransient) {
 // 如果已经通过拉获得了消息,则推的消息不回调
 if (client.getStorage().containMessage(message)) {
  return;
 }
 // hasMore 才设为 breakpoint
 // LogUtil.log.i("hasMore = " + hasMore);\
 if (!isTransient && AVIMOptions.getGlobalOptions().isMessageQueryCacheEnabled()) {
  client.getStorage().insertMessage(message, hasMore);
 }
 message = parseTypedMessage(message);
 final AVIMConversation conversation = client.getConversation(message.getConversationId(), convType);
 conversation.setLastMessage(message);
 if (!isTransient) {
  conversation.increaseUnreadCount(1, message.mentioned());
 }
 conversation.setLastMessageAt(new Date(message.getTimestamp()));
 retrieveAllMessageHandlers(message, conversation, false);
}
origin: cn.leancloud/realtime-core

/**
 * get an existed Chatroom by id
 * @param conversationId
 * @return
 */
public AVIMConversation getChatRoom(String conversationId) {
 return this.getConversation(conversationId, true, false);
}
origin: cn.leancloud/realtime-core

void onConversationDeliveredAtEvent(final long deliveredAt) {
 final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler();
 if (handler != null) {
  AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId());
  final AVIMConversation conversation = client.getConversation(this.conversationId);
  refreshConversationThenNotify(conversation, new SimpleCallback() {
   @Override
   public void done() {
    handler.processEvent(Conversation.STATUS_ON_MESSAGE_DELIVERED, deliveredAt, null, conversation);
   }
  });
 }
}
private String conversationGene = null;
cn.leancloud.im.v2AVIMClient

Most used methods

  • getInstance
    get AVIMClient instance by clientId and tag.
  • <init>
  • close
    close client.
  • createConversation
    Create a new Conversation
  • createTemporaryConversation
    Create a new temporary Conversation
  • getChatRoom
    get an existed Chatroom by id
  • getClientEventHandler
  • getClientId
    获取当前用户的 clientId
  • getClientsCount
    count used clients.
  • getConversation
  • getDefaultClient
    get default clientId.
  • getServiceConversation
    get an existed Service Conversation
  • getDefaultClient,
  • getServiceConversation,
  • getStorage,
  • getTemporaryConversation,
  • localClose,
  • mergeConversationCache,
  • open,
  • queryConvMemberThroughNetwork,
  • queryConversationMemberInfo,
  • realtimeSessionTokenExpired

Popular in Java

  • Parsing JSON documents to java classes using gson
  • startActivity (Activity)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • requestLocationUpdates (LocationManager)
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now