on master help sign in
git clone ssh://git.iko.soy/websuck1t

A server example with WebSockets

url: https://websuck1t.herokuapp.com

Methods

GET /posts/all

Response:

{
    "token": 1,
    "response": [
        {
            "postBody": "This is the post body",
            "postAuthor": 4,
            "postId": 1
        },
        {
            "postBody": "This is another post body",
            "postAuthor": 4,
            "postId": 2
        },
        {
            "postBody": "This is the post body",
            "postAuthor": 7,
            "postId": 3
        },
        {
            "postBody": "This is another post body",
            "postAuthor": 7,
            "postId": 4
        },
        {
            "postBody": "This is the post body",
            "postAuthor": 92,
            "postId": 5
        },
        {
            "postBody": "This is another post body",
            "postAuthor": 92,
            "postId": 6
        }
    ]
}

GET /users/:id

Retrieves a user with the given id.

If there is no user with the given id, the method returns error 404.

Captures:

Response:

{
    "userName": {
        "secondName": "Leonidovich",
        "firstName": "Seva"
    },
    "userId": 1
}
{
    "userName": {
        "secondName": "Barovich",
        "firstName": "Foo"
    },
    "userId": 42
}
{
    "userName": {
        "secondName": "Fooovich",
        "firstName": "Bar"
    },
    "userId": 69
}
{
    "userName": {
        "secondName": "Quixovich",
        "firstName": "Qux"
    },
    "userId": 8
}

WebSocket /posts/subscribe/:token

You access the web socket with the web socket protocol. I. e. https:// -> ws://.

Open a web socket from the given token for receiving events about new and deleted posts.

Returns error 498 if the supplied token has expired or is invalid.

Captures:

Response:

{
    "token": 1828,
    "response": {
        "deleted": [
            1819,
            1835,
            1843
        ],
        "added": [
            1844,
            1845,
            1846
        ]
    }
}

GET /posts/:id

If there is no post with the given id, the method returns error 404.

Captures:

Response:

{
    "postBody": "This is the post body",
    "postAuthor": 4,
    "postId": 1
}
{
    "postBody": "This is another post body",
    "postAuthor": 4,
    "postId": 1
}
{
    "postBody": "This is the post body",
    "postAuthor": 7,
    "postId": 1
}
{
    "postBody": "This is another post body",
    "postAuthor": 7,
    "postId": 1
}
{
    "postBody": "This is the post body",
    "postAuthor": 92,
    "postId": 1
}