Reputation: 3235
I am building a web chat over WebSockets using Cowboy and gproc.
Now, I would like to know if you could address me some projects or resources or snippet of code in order to migrate from simple websocket (ws) to web socket secure connection (wss).
Is there any way I can modify the cowboy example about WebSockets to make a chat application?
Upvotes: 1
Views: 1248
Reputation: 362
I use sockjs with cowboy
Cowboy
SockjsState = sockjs_handler:init_state(<<"/ws">>, fun my_sockjs_handler:hook/3, state, []),
Dispatch = cowboy_router:compile([
{'_', [
{<<"/ws/[...]">>,sockjs_cowboy_handler, SockjsState}
,{'_', my_handler, []}
]}
]),
{ok, _} = cowboy:start_https(https, 100, [
{port, 443},
{cacertfile, "priv/ssl/my_cacertfile.crt"},
{certfile, "priv/ssl/my_certfile.crt"},
{keyfile, "priv/ssl/my_key_file.key"}
], [{env, [{dispatch, Dispath}]}]),
Sockjs
var socket = new SockJS('/ws')
And it works pretty fine on https
Upvotes: 1