Skip to content

Commit

Permalink
added message splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
naxuroqa committed Jul 21, 2014
1 parent 5069bcb commit 314d27a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/core/ToxSession.vala
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,16 @@ namespace Venom {
public uint32 send_message(int friend_number, string message)
requires(message != null)
{
lock(handle) {
return handle.send_message(friend_number, message.data);
unowned string message_ptr = message;
lock(handle) {
while(message_ptr.length > Tox.MAX_MESSAGE_LENGTH) {
int offset = Tox.MAX_MESSAGE_LENGTH - 1;
unichar c;
message_ptr.get_prev_char(ref offset, out c);
handle.send_message(friend_number, message_ptr.data, offset);
message_ptr = message_ptr.offset(offset);
}
return handle.send_message(friend_number, message_ptr.data, message_ptr.length);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/vapi/tox-1.0.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ namespace Tox {
* m_sendmessage_withid will send a message with the id of your choosing,
* however we can generate an id for you by calling plain m_sendmessage.
*/
public uint32 send_message(int32 friendnumber, [CCode(array_length_type="guint32")] uint8[] message);
public uint32 send_message_withid(int32 friendnumber, uint32 theid, [CCode(array_length_type="guint32")] uint8[] message);
public uint32 send_message(int32 friendnumber, [CCode(array_length=false)] uint8[] message, uint32 length);
public uint32 send_message_withid(int32 friendnumber, uint32 theid, [CCode(array_length=false)] uint8[] message, uint32 length);

/* Send an action to an online friend.
*
Expand Down

0 comments on commit 314d27a

Please sign in to comment.