DOCUmenu

Chat Module

Using the chat module you can create conversations with multiple other attendees. Attendees may be selected during a conversation from all your apps users. Each user can send messages, including images or files and follow the other users messages in the conversation.

module_icon_chat

Configuration

Nothing to configure here.

Usage

The chat module provides you the class ConversationModel, a container for a conversation containing all attended users as a list and all messages, covered by the MessageModel class.

To start a conversation, simply create a new object of it and add at least the current user as attendee:

ConversationModel conv = new ConversationModel();
List<String> userNames = ...;
conv.setAttendeeUserNames( userNames );
conv.saveAsync(new AOMEmptyCallback() {
	@Override
	public void isDone(ApiomatRequestException exception) {
		if (exception != null) {
			// ...
		}
	}
});
AOMConversationModel *conv = [[AOMConversationModel alloc] init];
    NSMutableArray *userNames = [[NSMutableArray alloc] initWithObjects:@"user1", @"user2", nil];
    [conv setAttendeeUserNames: userNames];
    [conv saveAsyncWithBlock:^(NSError *error) {
        sendMessage(conv);
    }];
 
var conv= new Apiomat.ConversationModel();
var userNames=['< ...>'];

conv.setAttendeeUserNames(userNames);

var saveCB = {
    onOk : function() {
    	console.log("saved");
    },
    onError : function(error) {
        console.log("Some error occured: (" + error.statusCode + ")" + error.message);
    }
};
conv.save(saveCB);

Now that the conversation itself exists, one may post messages on it:

ChatMessageModel cmm = new ChatMessageModel( );
cmm.setText( "hi all" );
cmm.setSenderUserName( "JohnDoe" );
cmm.sendAsync(conv.getHref(), new AOMEmptyCallback() {
	@Override
	public void isDone(ApiomatRequestException exception) {
		if (exception != null) {
			// ...
		}
	}
});
void sendMessage(AOMConversationModel *conv)
{
    AOMChatMessageModel *mm = [[AOMChatMessageModel alloc] init];
    [mm setText:@"hi all"];
    [mm setSenderUserName:@"JohnDoe"];
    [mm sendAsync:[conv getHref] andWithBlock:^(NSError *error) {

    }];
}
 
var cmm= new Apiomat.ChatMessageModel();
cmm.setText( "hi all" );
cmm.setSenderUserName( "JohnDoe" );

var saveCB = {
    onOk : function() {
    	console.log("saved");
    },
    onError : function(error) {
        console.log("Some error occured: (" + error.statusCode + ")" + error.message);
    }
};
cmm.save(saveCB);

If you have also added the Push module, receivers will get a push directly when new messages are sent to them.

Example

A complete android app using this module can be found at Github. Please feel free to adopt it to your needs, it’s open source!

Username / Email
Password

Login
You don't have an account yet?
Signup
Get your free test version.
Username
Email
Password
Retype password

Signup
Do you already have an account?
Login