本文整理汇总了Java中com.twilio.chat.Channel类的典型用法代码示例。如果您正苦于以下问题:Java Channel类的具体用法?Java Channel怎么用?Java Channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Channel类属于com.twilio.chat包,在下文中一共展示了Channel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserChannels
import com.twilio.chat.Channel; //导入依赖的package包/类
@ReactMethod
public void getUserChannels(final Promise promise) {
channels().getUserChannels(new CallbackListener<Paginator<Channel>>() {
@Override
public void onError(final ErrorInfo errorInfo) {
super.onError(errorInfo);
promise.reject("get-user-channels-error", "Error occurred while attempting to getUserChannels.");
}
@Override
public void onSuccess(final Paginator<Channel> channelPaginator) {
for (Channel channel: channelPaginator.getItems()) {
createListener(channel);
}
String uuid = RCTTwilioChatPaginator.setPaginator(channelPaginator);
promise.resolve(RCTConvert.Paginator(channelPaginator, uuid, "Channel"));
}
});
}
示例2: createChannel
import com.twilio.chat.Channel; //导入依赖的package包/类
@ReactMethod
public void createChannel(ReadableMap options, final Promise promise) {
final JSONObject attributes = RCTConvert.readableMapToJson(options.getMap("attributes"));
final String uniqueName = options.getString("uniqueName");
String friendlyName = options.getString("friendlyName");
Channel.ChannelType type = (options.getString("type").compareTo("CHANNEL_TYPE_PRIVATE") == 0) ? Channel.ChannelType.PRIVATE : Channel.ChannelType.PUBLIC;
channels().channelBuilder()
.withUniqueName(uniqueName)
.withFriendlyName(friendlyName)
.withType(type)
.withAttributes(attributes)
.build(new CallbackListener<Channel>() {
@Override
public void onError(final ErrorInfo errorInfo) {
super.onError(errorInfo);
promise.reject("create-channel-error", "Error occurred while attempting to createChannel.");
}
@Override
public void onSuccess(final Channel newChannel) {
promise.resolve(RCTConvert.Channel(newChannel));
}
});
}
示例3: Channel
import com.twilio.chat.Channel; //导入依赖的package包/类
public static WritableMap Channel(Channel channel) {
WritableMap map = Arguments.createMap();
map.putString("sid", channel.getSid());
map.putString("friendlyName", channel.getFriendlyName());
map.putString("uniqueName", channel.getUniqueName());
map.putString("status", channel.getStatus().toString());
map.putString("type", channel.getType().toString());
map.putString("synchronizationStatus", channel.getSynchronizationStatus().toString());
map.putString("dateCreated", channel.getDateCreated().toString());
map.putString("dateUpdated", channel.getDateUpdated().toString());
WritableMap attributes = Arguments.createMap();
try {
attributes = jsonToWritableMap(channel.getAttributes());
}
catch (JSONException e) {}
map.putMap("attributes", attributes);
return map;
}
示例4: Paginator
import com.twilio.chat.Channel; //导入依赖的package包/类
public static WritableMap Paginator(Object paginator, String sid, String type) {
WritableMap map = Arguments.createMap();
WritableMap _paginator = Arguments.createMap();
switch (type) {
case "Channel":
_paginator.putArray("items", Channels(((Paginator<Channel>)paginator).getItems()));
_paginator.putBoolean("hasNextPage", ((Paginator<Channel>)paginator).hasNextPage());
break;
case "ChannelDescriptor":
_paginator.putArray("items", ChannelDescriptors(((Paginator<ChannelDescriptor>)paginator).getItems()));
_paginator.putBoolean("hasNextPage", ((Paginator<ChannelDescriptor>)paginator).hasNextPage());
break;
case "Member":
_paginator.putArray("items", Members(((Paginator<Member>)paginator).getItems()));
_paginator.putBoolean("hasNextPage", ((Paginator<Member>)paginator).hasNextPage());
break;
}
map.putString("sid", sid);
map.putString("type", type);
map.putMap("paginator", _paginator);
return map;
}
示例5: requestNextPageChannels
import com.twilio.chat.Channel; //导入依赖的package包/类
public void requestNextPageChannels(String sid, final Promise promise) {
final RCTTwilioChatPaginator tmp = RCTTwilioChatPaginator.getInstance();
Paginator<Channel> _paginator = (Paginator<Channel>)tmp.paginators.get(sid);
_paginator.requestNextPage(new CallbackListener<Paginator<Channel>>() {
@Override
public void onError(ErrorInfo errorInfo) {
super.onError(errorInfo);
promise.reject("request-next-page", "Error occurred while attempting to request the next page. Error Message: " + errorInfo.getErrorText());
}
@Override
public void onSuccess(Paginator<Channel> paginator) {
String uuid = RCTTwilioChatPaginator.setPaginator(paginator);
promise.resolve(RCTConvert.Paginator(paginator, uuid, "Channel"));
}
});
}
示例6: setCurrentChannel
import com.twilio.chat.Channel; //导入依赖的package包/类
public void setCurrentChannel(Channel currentChannel, final StatusListener handler) {
if (currentChannel == null) {
this.currentChannel = null;
return;
}
if (!currentChannel.equals(this.currentChannel)) {
setMessageInputEnabled(false);
this.currentChannel = currentChannel;
this.currentChannel.addListener(this);
if (this.currentChannel.getStatus() == Channel.ChannelStatus.JOINED) {
loadMessages(handler);
} else {
this.currentChannel.join(new StatusListener() {
@Override
public void onSuccess() {
loadMessages(handler);
}
@Override
public void onError(ErrorInfo errorInfo) {
}
});
}
}
}
示例7: extractAndSortFromChannelDescriptor
import com.twilio.chat.Channel; //导入依赖的package包/类
public void extractAndSortFromChannelDescriptor(Paginator<ChannelDescriptor> paginator,
final TaskCompletionListener<List<Channel>, String> listener) {
extractFromChannelDescriptor(paginator, new TaskCompletionListener<List<Channel>, String>() {
@Override
public void onSuccess(List<Channel> channels) {
Collections.sort(channels, new CustomChannelComparator());
listener.onSuccess(channels);
}
@Override
public void onError(String s) {
listener.onError(s);
}
});
}
示例8: extractFromChannelDescriptor
import com.twilio.chat.Channel; //导入依赖的package包/类
private void extractFromChannelDescriptor(Paginator<ChannelDescriptor> paginator,
final TaskCompletionListener<List<Channel>, String> listener) {
final List<Channel> channels = new ArrayList<>();
final AtomicInteger channelDescriptorCount = new AtomicInteger(paginator.getItems().size());
for (ChannelDescriptor channelDescriptor : paginator.getItems()) {
channelDescriptor.getChannel(new CallbackListener<Channel>() {
@Override
public void onSuccess(Channel channel) {
channels.add(channel);
int channelDescriptorsLeft = channelDescriptorCount.decrementAndGet();
if(channelDescriptorsLeft == 0) {
listener.onSuccess(channels);
}
}
@Override
public void onError(ErrorInfo errorInfo) {
listener.onError(errorInfo.getErrorText());
}
});
}
}
示例9: createChannelWithName
import com.twilio.chat.Channel; //导入依赖的package包/类
public void createChannelWithName(String name, final StatusListener handler) {
this.channelsObject
.channelBuilder()
.withFriendlyName(name)
.withType(ChannelType.PUBLIC)
.build(new CallbackListener<Channel>() {
@Override
public void onSuccess(final Channel newChannel) {
handler.onSuccess();
}
@Override
public void onError(ErrorInfo errorInfo) {
handler.onError(errorInfo);
}
});
}
示例10: createGeneralChannelWithCompletion
import com.twilio.chat.Channel; //导入依赖的package包/类
private void createGeneralChannelWithCompletion(final StatusListener listener) {
this.channelsObject
.channelBuilder()
.withFriendlyName(defaultChannelName)
.withUniqueName(defaultChannelUniqueName)
.withType(ChannelType.PUBLIC)
.build(new CallbackListener<Channel>() {
@Override
public void onSuccess(final Channel channel) {
ChannelManager.this.generalChannel = channel;
ChannelManager.this.channels.add(channel);
joinGeneralChannelWithCompletion(listener);
}
@Override
public void onError(ErrorInfo errorInfo) {
listener.onError(errorInfo);
}
});
}
示例11: joinChannel
import com.twilio.chat.Channel; //导入依赖的package包/类
private void joinChannel(final Channel selectedChannel) {
runOnUiThread(new Runnable() {
@Override
public void run() {
chatFragment.setCurrentChannel(selectedChannel, new StatusListener() {
@Override
public void onSuccess() {
MainChatActivity.this.stopActivityIndicator();
}
@Override
public void onError(ErrorInfo errorInfo) {
}
});
setTitle(selectedChannel.getFriendlyName());
drawer.closeDrawer(GravityCompat.START);
}
});
}
示例12: leaveCurrentChannel
import com.twilio.chat.Channel; //导入依赖的package包/类
private void leaveCurrentChannel() {
final Channel currentChannel = chatFragment.getCurrentChannel();
if (currentChannel.getStatus() == Channel.ChannelStatus.NOT_PARTICIPATING) {
setChannel(0);
return;
}
channelManager.leaveChannelWithHandler(currentChannel, new StatusListener() {
@Override
public void onSuccess() {
setChannel(0);
}
@Override
public void onError(ErrorInfo errorInfo) {
stopActivityIndicator();
}
});
}
示例13: joinChannel
import com.twilio.chat.Channel; //导入依赖的package包/类
private void joinChannel(final Channel channel) {
Log.d(TAG, "Joining Channel: " + channel.getUniqueName());
channel.join(new StatusListener() {
@Override
public void onSuccess() {
mGeneralChannel = channel;
Log.d(TAG, "Joined default channel");
mGeneralChannel.addListener(mDefaultChannelListener);
}
@Override
public void onError(ErrorInfo errorInfo) {
Log.e(TAG,"Error joining channel: " + errorInfo.getMessage());
}
});
}
示例14: loadMembersFromChannelSid
import com.twilio.chat.Channel; //导入依赖的package包/类
private void loadMembersFromChannelSid(String sid, final CallbackListener<Members> callbackListener) {
RCTTwilioChatClient.getInstance().client.getChannels().getChannel(sid, new CallbackListener<Channel>() {
@Override
public void onSuccess(final Channel channel) {
callbackListener.onSuccess(channel.getMembers());
};
@Override
public void onError(final ErrorInfo errorInfo){
callbackListener.onError(errorInfo);
}
});
}
示例15: loadMessagesFromChannelSid
import com.twilio.chat.Channel; //导入依赖的package包/类
private void loadMessagesFromChannelSid(String sid, final CallbackListener<Messages> callbackListener) {
RCTTwilioChatClient.getInstance().client.getChannels().getChannel(sid, new CallbackListener<Channel>() {
@Override
public void onSuccess(final Channel channel) {
callbackListener.onSuccess(channel.getMessages());
}
@Override
public void onError(final ErrorInfo errorInfo) {
callbackListener.onError(errorInfo);
}
});
}