當前位置: 首頁>>代碼示例>>Java>>正文


Java Channel類代碼示例

本文整理匯總了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"));
        }
    });
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:20,代碼來源:RCTTwilioChatChannels.java

示例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));
                }
            });
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:26,代碼來源:RCTTwilioChatChannels.java

示例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;
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:20,代碼來源:RCTConvert.java

示例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;
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:23,代碼來源:RCTConvert.java

示例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"));
        }
    });
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:19,代碼來源:RCTTwilioChatPaginator.java

示例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) {
        }
      });
    }
  }
}
 
開發者ID:TwilioDevEd,項目名稱:twiliochat-android,代碼行數:26,代碼來源:MainChatFragment.java

示例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);
    }
  });
}
 
開發者ID:TwilioDevEd,項目名稱:twiliochat-android,代碼行數:17,代碼來源:ChannelExtractor.java

示例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());
      }
    });
  }
}
 
開發者ID:TwilioDevEd,項目名稱:twiliochat-android,代碼行數:24,代碼來源:ChannelExtractor.java

示例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);
        }
      });
}
 
開發者ID:TwilioDevEd,項目名稱:twiliochat-android,代碼行數:18,代碼來源:ChannelManager.java

示例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);
        }
      });
}
 
開發者ID:TwilioDevEd,項目名稱:twiliochat-android,代碼行數:21,代碼來源:ChannelManager.java

示例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);
    }
  });
}
 
開發者ID:TwilioDevEd,項目名稱:twiliochat-android,代碼行數:20,代碼來源:MainChatActivity.java

示例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();
    }
  });
}
 
開發者ID:TwilioDevEd,項目名稱:twiliochat-android,代碼行數:19,代碼來源:MainChatActivity.java

示例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());
        }
    });
}
 
開發者ID:TwilioDevEd,項目名稱:chat-quickstart-android,代碼行數:17,代碼來源:MainActivity.java

示例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);
        }
    });
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:14,代碼來源:RCTTwilioChatMembers.java

示例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);
        }
    });
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:14,代碼來源:RCTTwilioChatMessages.java


注:本文中的com.twilio.chat.Channel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。