本文整理汇总了Java中com.twilio.chat.ChatClient类的典型用法代码示例。如果您正苦于以下问题:Java ChatClient类的具体用法?Java ChatClient怎么用?Java ChatClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChatClient类属于com.twilio.chat包,在下文中一共展示了ChatClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectClient
import com.twilio.chat.ChatClient; //导入依赖的package包/类
public void connectClient(final TaskCompletionListener<Void, String> listener) {
ChatClient.setLogLevel(android.util.Log.DEBUG);
accessTokenFetcher.fetch(new TaskCompletionListener<String, String>() {
@Override
public void onSuccess(String token) {
createAccessManager(token);
buildClient(token, listener);
}
@Override
public void onError(String message) {
if (listener != null) {
listener.onError(message);
}
}
});
}
示例2: ChatClient
import com.twilio.chat.ChatClient; //导入依赖的package包/类
public static WritableMap ChatClient(ChatClient client) {
WritableMap map = Arguments.createMap();
map.putMap("userInfo", UserInfo(client.getMyUserInfo()));
map.putBoolean("isReachabilityEnabled", client.isReachabilityEnabled());
return map;
}
示例3: createClient
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@ReactMethod
public void createClient(String token, ReadableMap props, final Promise promise) {
final RCTTwilioChatClient tmp = RCTTwilioChatClient.getInstance();
ChatClient.Properties.Builder builder = new ChatClient.Properties.Builder();
if (props != null) {
if (props.hasKey("initialMessageCount")) {
builder.setInitialMessageCount(props.getInt("initialMessageCount"));
}
if (props.hasKey("synchronizationStrategy")) {
builder.setSynchronizationStrategy(ChatClient.SynchronizationStrategy.valueOf(props.getString("synchronizationStrategy")));
}
}
ChatClient.create(reactContext, token, builder.createProperties(), new CallbackListener<ChatClient>() {
@Override
public void onError(ErrorInfo errorInfo) {
super.onError(errorInfo);
promise.reject("create-client-error", "Error occurred while attempting to create the client. Error Message: " + errorInfo.getErrorText());
}
@Override
public void onSuccess(ChatClient twilioChatClient) {
tmp.client = twilioChatClient;
tmp.client.setListener(tmp);
promise.resolve(RCTConvert.ChatClient(tmp.client));
}
});
}
示例4: buildClient
import com.twilio.chat.ChatClient; //导入依赖的package包/类
private void buildClient(String token, final TaskCompletionListener<Void, String> listener) {
chatClientBuilder.build(token, new TaskCompletionListener<ChatClient, String>() {
@Override
public void onSuccess(ChatClient chatClient) {
ChatClientManager.this.chatClient = chatClient;
listener.onSuccess(null);
}
@Override
public void onError(String message) {
listener.onError(message);
}
});
}
示例5: build
import com.twilio.chat.ChatClient; //导入依赖的package包/类
public void build(String token, final TaskCompletionListener<ChatClient, String> listener) {
ChatClient.Properties props =
new ChatClient.Properties.Builder()
.setSynchronizationStrategy(ChatClient.SynchronizationStrategy.CHANNELS_LIST)
.setRegion("us1")
.createProperties();
this.buildListener = listener;
ChatClient.create(context.getApplicationContext(),
token,
props,
this);
}
示例6: retrieveAccessTokenfromServer
import com.twilio.chat.ChatClient; //导入依赖的package包/类
private void retrieveAccessTokenfromServer() {
String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
String tokenURL = SERVER_TOKEN_URL + "?device=" + deviceId + "&identity=" + mIdentity;
Ion.with(this)
.load(tokenURL)
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e == null) {
String accessToken = result.get("token").getAsString();
setTitle(mIdentity);
ChatClient.Properties.Builder builder = new ChatClient.Properties.Builder();
builder.setSynchronizationStrategy(ChatClient.SynchronizationStrategy.ALL);
ChatClient.Properties props = builder.createProperties();
ChatClient.create(MainActivity.this,accessToken,props,mChatClientCallback);
} else {
Log.e(TAG,e.getMessage(),e);
Toast.makeText(MainActivity.this,
R.string.error_retrieving_access_token, Toast.LENGTH_SHORT)
.show();
}
}
});
}
示例7: getConstants
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
Map<String, String> channelStatus = new HashMap<>();
channelStatus.put("Invited", Channel.ChannelStatus.INVITED.toString());
channelStatus.put("Joined",Channel.ChannelStatus.JOINED.toString());
channelStatus.put("NotParticipating",Channel.ChannelStatus.NOT_PARTICIPATING.toString());
constants.put("TCHChannelStatus", channelStatus);
Map<String, String> channelSyncStatus = new HashMap<>();
channelSyncStatus.put("None",Channel.SynchronizationStatus.NONE.toString());
channelSyncStatus.put("Identifier",Channel.SynchronizationStatus.IDENTIFIER.toString());
channelSyncStatus.put("Metadata",Channel.SynchronizationStatus.METADATA.toString());
channelSyncStatus.put("All",Channel.SynchronizationStatus.ALL.toString());
channelSyncStatus.put("Failed",Channel.SynchronizationStatus.FAILED.toString());
constants.put("TCHChannelSynchronizationStatus", channelSyncStatus);
Map<String, String> channelType = new HashMap<>();
channelType.put("Public",Channel.ChannelType.PUBLIC.toString());
channelType.put("Private",Channel.ChannelType.PRIVATE.toString());
constants.put("TCHChannelType", channelType);
Map<String, String> clientSyncStatus = new HashMap<>();
clientSyncStatus.put("Started",ChatClient.SynchronizationStatus.STARTED.toString());
clientSyncStatus.put("ChannelListCompleted",ChatClient.SynchronizationStatus.CHANNELS_COMPLETED.toString());
clientSyncStatus.put("Completed",ChatClient.SynchronizationStatus.COMPLETED.toString());
clientSyncStatus.put("Failed",ChatClient.SynchronizationStatus.FAILED.toString());
constants.put("TCHClientSynchronizationStatus", clientSyncStatus);
Map<String, String> clientSyncStrategy = new HashMap<>();
clientSyncStrategy.put("All",ChatClient.SynchronizationStrategy.ALL.toString());
clientSyncStrategy.put("ChannelsList",ChatClient.SynchronizationStrategy.CHANNELS_LIST.toString());
constants.put("TCHClientSynchronizationStrategy", clientSyncStrategy);
Map<String, String> channelOption = new HashMap<>();
channelOption.put("FriendlyName", "friendlyName");
channelOption.put("UniqueName", "uniqueName");
channelOption.put("Type", "type");
channelOption.put("Attributes", "attributes");
constants.put("TCHChannelOption", channelOption);
Map<String, String> connectionState = new HashMap<>();
connectionState.put("Connecting", ChatClient.ConnectionState.CONNECTING.toString());
connectionState.put("Connected", ChatClient.ConnectionState.CONNECTED.toString());
connectionState.put("Disconnected", ChatClient.ConnectionState.DISCONNECTED.toString());
connectionState.put("Denied", ChatClient.ConnectionState.DENIED.toString());
connectionState.put("Error", ChatClient.ConnectionState.FATAL_ERROR.toString());
constants.put("TCHClientConnectionState", connectionState);
Map<String, Integer> logLevel = new HashMap<>();
logLevel.put("Fatal", Log.ERROR);
logLevel.put("Critical", Log.ERROR);
logLevel.put("Warning", Log.WARN);
logLevel.put("Info", Log.INFO);
logLevel.put("Debug", Log.DEBUG);
constants.put("TCHLogLevel", logLevel);
Map<String, String> userInfo = new HashMap<>();
userInfo.put("Attributes", UserInfo.UpdateReason.ATTRIBUTES.toString());
userInfo.put("FriendlyName", UserInfo.UpdateReason.FRIENDLY_NAME.toString());
userInfo.put("ReachabilityNotifiable", UserInfo.UpdateReason.REACHABILITY_NOTIFIABLE.toString());
userInfo.put("ReachabilityOnline", UserInfo.UpdateReason.REACHABILITY_ONLINE.toString());
constants.put("TCHUserInfoUpdate", userInfo);
return constants;
}
示例8: setLogLevel
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@ReactMethod
public void setLogLevel(Integer logLevel) {
ChatClient.setLogLevel(logLevel);
}
示例9: onConnectionStateChange
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@Override
public void onConnectionStateChange(ChatClient.ConnectionState state) {
sendEvent("chatClient:connectionStateChanged", state.toString());
}
示例10: onClientSynchronization
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@Override
public void onClientSynchronization(ChatClient.SynchronizationStatus synchronizationStatus) {
sendEvent("chatClient:synchronizationStatusChanged", synchronizationStatus.toString());
}
示例11: getChatClient
import com.twilio.chat.ChatClient; //导入依赖的package包/类
public ChatClient getChatClient() {
return this.chatClient;
}
示例12: setChatClient
import com.twilio.chat.ChatClient; //导入依赖的package包/类
public void setChatClient(ChatClient client) {
this.chatClient = client;
}
示例13: onSuccess
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@Override
public void onSuccess(ChatClient chatClient) {
this.buildListener.onSuccess(chatClient);
}
示例14: onSuccess
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@Override
public void onSuccess(ChatClient chatClient) {
mChatClient = chatClient;
loadChannels();
Log.d(TAG, "Success creating Twilio Chat Client");
}
示例15: onClientSynchronization
import com.twilio.chat.ChatClient; //导入依赖的package包/类
@Override
public void onClientSynchronization(ChatClient.SynchronizationStatus synchronizationStatus) {
}