Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GamgeeNL/websocket-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebsocketClient

This is a demonstration of how to use gun (Erlang) with a GenServer wrapper in Elixir.

Why would you want to do this? I suspect for testing your websocket capable server.

If you don't know why you would want to then this probably isn't for you.

As is it is just pinging echo.websocket.org for demonstration purposes. You'll have to point it somewhere else to do something smarter with it.

Installation

You need to have Elixir and Erlang installed.

Install dependencies

mix deps.get

Install dependencies and compile

mix deps.compile

Run

Once you have it installed.

iex -S mix

You need to open the websocket before attempting to send messages.

iex> WebsocketClient.Application.open_ws

Send messages and the replies come back automatically.

iex> WebsocketClient.Application.send_message("My name is Jonas!")

:ok

iex> 15:23:02.790 [info] Message received "My name is Jonas!"

Use set_from if you want to use it remotely...

iex> WebsocketClient.Application.set_from

15:26:41.332 [info] Sending... "I love you"

15:26:41.449 [info] I love you more!

I promise this makes sense if you look at the code. :)

That's it! Have fun.

About

Elixir GenServer wrapper of gun functionality.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages