Skip to content

Socket Events API

Event Handlers

onlineChats

Online chats of connected user.

RECEIVED PACKET
{
    contacts: ["bowl@example.com", "bowl2@example.com"...],
    groups: [
        {
            groupId: "12 byte unique group id1",
            persons: ["bowl2@example.com", "bowl3@example.com"...]
        },
        {
            groupId: "12 byte unique group id2",
            persons: ["bowl@example.com", "bowl4@example.com"...]
        }
        ...
    ]
}

contactChatMessage

Message packet that received from contact. Message has to be decrypted using private key of connected user.

RECEIVED PACKET
{
    messageType: <Any>,
    message: "This received contact message is encrypted",
    date: "DD/MM/YY",
    time: "16:24",
    from: "bowl@example.com"
}

groupChatMessage

Message packet that received from group. Message has to be decrypted using group key.

RECEIVED PACKET
{
    groupId: "12 byte unique group id.",
    messageType: <Any>,
    message: "This received group message is encrypted",
    date: "DD/MM/YY",
    time: "16:24",
    from: "bowl@example.com"
}

connect_error

Socker error handling.

RECEIVED PACKET
Object(Error)

online

Person become online.

RECEIVED PACKET
{
    email: "bowl@example.com"
}

offline

Person become offline.

RECEIVED PACKET
{
    email: "bowl@example.com"
}

contactRequestReceived

Received contact request packet.

RECEIVED PACKET
{
    name: "Bowl",
    email: "bowl@example.com",
    publicKey: Base64(PublicKey(type: "spki", format: "der"))
}

groupRequestReceived

Received group request packet. Encrypted group key has to be decrypted using private key of connected user. Decrypted group key format is AES256.

RECEIVED PACKET
{
    name: "The Bowl Group",
    description: "This is description of group.",
    groupId: "12 byte unique group id.",
    encryptedGroupKey: "This is encrypted group key that encrypted with public key of connected user"
}

newGroupMember

Received new group member packet.

RECEIVED PACKET
{
    groupId: "12 byte unique group id.",
    name: "Member",
    email: "bowl@example.com",
    publicKey: Base64(PublicKey(type: "spki", format: "der"))
}

Event Emitters

contactChatMessage

Send encrypted chat message to contact. Message has to be encrypted using public key of contact.

SEND
{
    date: "DD/MM/YYYY",
    time: "01:23",
    messageType: <Any>,
    message: "This sent contact message is encrypted",
    to: "bowl@example.com"
}
RECEIVED PACKET
{
    status: "OK"
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}

groupChatMessage

Send encrypted chat message to group. Message has to be encrypted using group key.

SEND
{
    groupId: "12 byte unique group id.",
    date: "DD/MM/YYYY",
    time: "01:23",
    messageType: <Any>,
    message: "This sent group message is encrypted",
}
RECEIVED PACKET
{
    status: "OK"
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}

acceptContactRequest

Accept contact request that received.

SEND
{
    email: "bowl@example.com"
}
RECEIVED PACKET
{
    status: "OK"
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}

declineContactRequest

Decline contact request that received.

SEND
{
    email: "bowl@example.com"
}
RECEIVED PACKET
{
    status: "OK"
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}

sendContactRequest

Send contact request to person.

SEND
{
    email:"bowl@example.com"
}
RECEIVED PACKET
{
    status: "OK",
    contactData: {
        name: "Contact Name",
        email: "bowl@example.com",
        publicKey: Base64(PublicKey(type: "spki", format: "der"))
    }
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}

acceptGroupRequest

Accept group request that received.

SEND
{
    groupId: "12 byte unique group id."
}
RECEIVED PACKET
{
    status: "OK"
    members: [
        {
            name: "Bowl",
            email: "bowl@example.com",
            publicKey: Base64(PublicKey(type: "spki", format: "der")),
            isAdmin: True
        },
        {
            name: "Bowl2",
            email: "bowl2@example.com",
            publicKey: Base64(PublicKey(type: "spki", format: "der")),
            isAdmin: false
        },
        {
            name: "Bowl3",
            email: "bowl3@example.com",
            publicKey: Base64(PublicKey(type: "spki", format: "der")),
            isAdmin: true
        }
        ...
    ]
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}

declineGroupRequest

Decline group request that received.

SEND
{
    groupId: "12 byte unique group id."
}
RECEIVED PACKET
{
    status: "OK"
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}

sendGroupRequest

Send group request to person. Group key has to be encrypted using public key of person. In order to encrypt key connected user needs to get public key of person.

SEND
{
    groupId: "12 byte unique group id."
    encryptedGroupKey: "This is encrypted group key that encrypted with public key of target user",
    email:"bowl@example.com"
}
RECEIVED PACKET
{
    status: "OK",
}
RECEIVED PACKET
{
    status: "ERROR",
    error: "This is error message"
}