connectycube_sdk 0.2.0-beta2 copy "connectycube_sdk: ^0.2.0-beta2" to clipboard
connectycube_sdk: ^0.2.0-beta2 copied to clipboard

outdated

Flutter SDK for simple using ConnectyCube API features. Supports REST API and Realtime communication features.

example/example.md

Init ConnectyCube SDK #

String appId = "";
String authKey = "";
String authSecret = "";

init(appId, authKey, authSecret);

Create session #

CubeUser user = CubeUser(login: "user_login", password: "super_sequre_password");

createSession(user).then((cubeSession){
  print("Session was created");
}).catchError((error){
  print("Error was occured during create sessin");
});

Login to the chat #

CubeUser user = CubeUser(id: 123456, login: "user_login", password: "super_sequre_password");
    
CubeChatConnection.instance.login(user).then((user){
  print("Success login to the chat");
}).catchError((error){
  print("Error was occured during login to the chat");
});

Dialogs #

All chats between users are organized in dialogs. The are 3 types of dialogs:

  • 1-1 chat - a dialog between 2 users.
  • group chat - a dialog between specified list of users.
  • public group chat - an open dialog. Any user from your app can chat there.
  • broadcast - chat where a message is sent to all users within application at once. All the users from the application are able to join this group. Broadcast dialogs can be created only via Admin panel.

You need to create a new dialog and then use it to chat with other users. You also can obtain a list of your existing dialogs.

Create new dialog #

Create 1-1 chat #

You need to pass type = CubeDialogType.PRIVATE and an id of an opponent you want to create a chat with:

CubeDialog newDialog = CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [56]);

createDialog(newDialog)
    .then((createdDialog) {})
    .catchError((error) {});

Create group chat #

You need to pass type = CubeDialogType.GROUP and ids of opponents you want to create a chat with:

CubeDialog newDialog = CubeDialog(
    CubeDialogType.GROUP,
    name: "Hawaii relax team",
    description: "Some description",
    occupantsIds: [56, 98, 34],
    photo: "https://some.url/to/avatar.jpeg");

  createDialog(newDialog)
      .then((createdDialog) {})
      .catchError((error) {});

Create public group chat #

It's possible to create a public group chat, so any user from you application can join it. There is no a list with occupants,
this chat is just open for everybody.

You need to pass type = CubeDialogType.PUBLIC and ids of opponents you want to create a chat with:

CubeDialog newDialog = CubeDialog(
    CubeDialogType.PUBLIC,
    name: "Blockchain trends",
    description: "Public dialog Description",
    photo: "https://some.url/to/avatar.jpeg");

createDialog(newDialog)
    .then((createdDialog) {})
    .catchError((error) {});

Send/Receive chat messages #

CubeDialog cubeDialog;  // some dialog, which must contains opponent's id in 'occupantsIds' for CubeDialogType.PRIVATE and
                        // 'dialogId' for other types of dialogs
CubeMessage message = CubeMessage();
message.body = "How are you today?";
message.dateSent = DateTime.now().millisecondsSinceEpoch;
message.markable = true;
message.saveToHistory = true;
      
cubeDialog.sendMessage(message)
    .then((cubeMessage) {})
    .catchError((error) {});

// to listen messages
ChatMessagesManager chatMessagesManager = CubeChatConnection.instance.chatMessagesManager;
chatMessagesManager.chatMessagesStream.listen((newMessage) {
    // new message received
}).onError((error) {
    // error received
});

Calls #

Setup P2PClient #

P2PClient callClient = P2PClient.instance; // returns instance of P2PClient

Create call session #

Set<int> opponentsIds = {};
int callType = CallType.VIDEO_CALL; // or CallType.AUDIO_CALL

P2PSession callSession = callClient.createCallSession(callType, opponentsIds);

Start call #

Map<String, String> additionalInfo = {};
callSession.startCall(additionalInfo);

Accept call #

Map<String, String> additionalInfo = {}; // additional info for other call members
callSession.acceptCall(additionalInfo);

End a call #

Map<String, String> additionalInfo = {}; // additional info for other call members
callSession.hungUp(additionalInfo);
76
likes
0
pub points
90%
popularity

Publisher

verified publisherconnectycube.com

Flutter SDK for simple using ConnectyCube API features. Supports REST API and Realtime communication features.

Homepage
View/report issues

Documentation

Documentation

Dependencies

crossplat_objectid, crypto, device_id, flutter, flutter_webrtc, http, http_parser, intl, mime, package_info, path, uuid, xmpp_stone

More

Packages that depend on connectycube_sdk