View Source XtbClient.MainSocket (XtbClient v0.1.1)

WebSocket server used for synchronous communication.

MainSocket is being used like standard GenServer - could be started with start_link/1 and supervised.

After successful connection to WebSocket the flow is:

  • process casts login command to obtain session with backend server,
  • process schedules to itself the ping command (with recurring interval) - to maintain persistent connection with backend.

Link to this section Summary

Functions

Casts query to get data from the backend server.

Starts a XtbClient.MainSocket process linked to the calling process.

Casts query to get streaming session ID.

Link to this section Types

@type client() :: atom() | pid() | {atom(), any()} | {:via, atom(), any()}

Link to this section Functions

Link to this function

query(server, caller, ref, method)

View Source
@spec query(client(), client(), term(), binary()) :: :ok

Casts query to get data from the backend server.

Might be also used to send command to the backend server.

arguments

Arguments

  • server pid of the main socket process,
  • caller pid of the caller awaiting for the result,
  • ref unique reference of the query,
  • method name of the query method,
  • params [optional] arguments of the method.

Result of the query will be delivered to message mailbox of the caller process.

Link to this function

query(server, caller, ref, method, params)

View Source
@spec query(client(), client(), term(), binary(), map()) :: :ok
@spec start_link(%{
  :app_name => binary(),
  :password => binary(),
  :type => XtbClient.AccountType.t(),
  :url => binary() | URI.t(),
  :user => binary(),
  optional(any()) => any()
}) :: GenServer.on_start()

Starts a XtbClient.MainSocket process linked to the calling process.

Link to this function

stream_session_id(server, caller)

View Source
@spec stream_session_id(client(), client()) :: :ok

Casts query to get streaming session ID.

arguments

Arguments

  • server pid of the main socket process,
  • caller pid of the caller awaiting for the result.

Result of the query will be delivered to message mailbox of the caller process.