Issue title: Server can't init a message then send to client?
 Issue body: Hi:
     I use libwebsockets write a linux server program,it works when client connect the server and send message up to server & server send a echo message back. However, when I init a message, use libwebsocket_write() and libwebsocket_callback_on_writable to try to send it to the client, it never show up. I print in the protocol callback, no LWS_CALLBACK_SERVER_WRITEABLE event callback.
And If I use client send a message up to server at this moment,the server init message will be sent together with the echo message back to client. Why is that happen? 

 Comments: 
 Comment 0: On 18 August 2014 19:06:35 GMT+08:00, yuz11 fkramer@example.net wrote:

> Hi:
> I use libwebsockets write a linux server program,it works when client
> connect the server and send message up to server & server send a echo
> message back. However, when I init a message, use libwebsocket_write()
> and libwebsocket_callback_on_writable to try to send it to the client,

No you should ask for a callback_on_writable() and do the libwebsocket_write() from the callback that says it was writeable.

> it never show up. I print in the protocol callback, no
> LWS_CALLBACK_SERVER_WRITEABLE event callback.
> And If I use client send a message up to server at this moment,the
> server init message will be sent together with the echo message back to
> client. Why is that happen? 

Are you doing the service loop calls like in the test server and client?

You code has to loop calling the service function (which basically waits for something to happen, sends notifications about being writeable etc)

-Andy

> ---
> 
> Reply to this email directly or view it on GitHub:
> https://github.com/warmcat/libwebsockets/issues/163

 Comment 1: now I write the loop like:

libwebsocket_create_context()
while()
{
    libwebsocket_service()
    libwebsocket_callback_on_writable()
}
and the call back:

case LWS_CALLBACK_SERVER_WRITEABLE :
init message
libwebsocket_write()

still no LWS_CALLBACK_SERVER_WRITEABLE event call back got.

any thing else wrong?

 Comment 2: Well, you should not have access to the client wsi to call callback_on_writeable() from there.

libwebsocket_callback_on_writable_all_protocol() can do it instead by giving all wsi that are using the struct protocols \* in the argument a callback when writeable.

Also the way you're doing it, the 2nd arg to libwebsocket_service() should be reasonably small so we go around the while loop without a long delay first.

 Comment 3: OK,I see.problem solve.thx~~

{'source': 'GithubIssues', 'repo_name_with_owner': 'warmcat/libwebsockets', 'issue_id': 40476883, 'repo_stars': 3687.0}